Skip to content

feat: evaluate provisioner tags #13333

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 9 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: tests
  • Loading branch information
mtojek committed May 21, 2024
commit 98e623ae48e5b5fa3ea529f4b055689bd516800b
2 changes: 1 addition & 1 deletion coderd/wsbuilder/wsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ func (b *Builder) getTemplateVersionWorkspaceTags() ([]database.TemplateVersionW
}

workspaceTags, err := b.store.GetTemplateVersionWorkspaceTags(b.ctx, templateVersion.ID)
if err != nil {
if err != nil && !xerrors.Is(err, sql.ErrNoRows) {
return nil, xerrors.Errorf("get template version workspace tags: %w", err)
}

Expand Down
16 changes: 16 additions & 0 deletions coderd/wsbuilder/wsbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestBuilder_NoOptions(t *testing.T) {
withLastBuildFound,
withRichParameters(nil),
withParameterSchemas(inactiveJobID, nil),
withWorkspaceTags(inactiveVersionID, nil),

// Outputs
expectProvisionerJob(func(job database.InsertProvisionerJobParams) {
Expand Down Expand Up @@ -112,6 +113,7 @@ func TestBuilder_Initiator(t *testing.T) {
withLastBuildFound,
withRichParameters(nil),
withParameterSchemas(inactiveJobID, nil),
withWorkspaceTags(inactiveVersionID, nil),

// Outputs
expectProvisionerJob(func(job database.InsertProvisionerJobParams) {
Expand Down Expand Up @@ -154,6 +156,7 @@ func TestBuilder_Baggage(t *testing.T) {
withLastBuildFound,
withRichParameters(nil),
withParameterSchemas(inactiveJobID, nil),
withWorkspaceTags(inactiveVersionID, nil),

// Outputs
expectProvisionerJob(func(job database.InsertProvisionerJobParams) {
Expand Down Expand Up @@ -188,6 +191,7 @@ func TestBuilder_Reason(t *testing.T) {
withLastBuildFound,
withRichParameters(nil),
withParameterSchemas(inactiveJobID, nil),
withWorkspaceTags(inactiveVersionID, nil),

// Outputs
expectProvisionerJob(func(job database.InsertProvisionerJobParams) {
Expand Down Expand Up @@ -813,6 +817,18 @@ func withRichParameters(params []database.WorkspaceBuildParameter) func(mTx *dbm
}
}

func withWorkspaceTags(versionID uuid.UUID, tags []database.TemplateVersionWorkspaceTag) func(mTx *dbmock.MockStore) {
return func(mTx *dbmock.MockStore) {
c := mTx.EXPECT().GetTemplateVersionWorkspaceTags(gomock.Any(), versionID).
Times(1)
if len(tags) > 0 {
c.Return(tags, nil)
} else {
c.Return(nil, sql.ErrNoRows)
}
}
}

// Since there is expected to be only one each of job, build, and build-parameters inserted, instead
// of building matchers, we match any call and then assert its parameters. This will feel
// more familiar to the way we write other tests.
Expand Down
Loading