Skip to content

feat(coderd/database/dbfake): allow specifying fileID in TemplateVersionBuilder #12450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions coderd/database/dbfake/dbfake.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ type TemplateVersionBuilder struct {
t testing.TB
db database.Store
seed database.TemplateVersion
fileID uuid.UUID
ps pubsub.Pubsub
resources []*sdkproto.Resource
params []database.TemplateVersionParameter
Expand All @@ -296,6 +297,12 @@ func (t TemplateVersionBuilder) Seed(v database.TemplateVersion) TemplateVersion
return t
}

func (t TemplateVersionBuilder) FileID(fid uuid.UUID) TemplateVersionBuilder {
// nolint: revive // returns modified struct
t.fileID = fid
return t
}

func (t TemplateVersionBuilder) Pubsub(ps pubsub.Pubsub) TemplateVersionBuilder {
// nolint: revive // returns modified struct
t.ps = ps
Expand All @@ -320,6 +327,8 @@ func (t TemplateVersionBuilder) Do() TemplateVersionResponse {
t.seed.OrganizationID = takeFirst(t.seed.OrganizationID, uuid.New())
t.seed.ID = takeFirst(t.seed.ID, uuid.New())
t.seed.CreatedBy = takeFirst(t.seed.CreatedBy, uuid.New())
// nolint: revive
t.fileID = takeFirst(t.fileID, uuid.New())
Comment on lines +330 to +331
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heads-up: the linter has started complaining about this, we may want to consider squelching this rule for this particular case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What rule is the problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


var resp TemplateVersionResponse
if t.seed.TemplateID.UUID == uuid.Nil {
Expand Down Expand Up @@ -361,6 +370,7 @@ func (t TemplateVersionBuilder) Do() TemplateVersionResponse {
Time: dbtime.Now(),
Valid: true,
},
FileID: t.fileID,
})

t.seed.JobID = job.ID
Expand Down