Skip to content

Commit 98e623a

Browse files
committed
fix: tests
1 parent fb2c92f commit 98e623a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

coderd/wsbuilder/wsbuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ func (b *Builder) getTemplateVersionWorkspaceTags() ([]database.TemplateVersionW
687687
}
688688

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

coderd/wsbuilder/wsbuilder_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func TestBuilder_NoOptions(t *testing.T) {
6060
withLastBuildFound,
6161
withRichParameters(nil),
6262
withParameterSchemas(inactiveJobID, nil),
63+
withWorkspaceTags(inactiveVersionID, nil),
6364

6465
// Outputs
6566
expectProvisionerJob(func(job database.InsertProvisionerJobParams) {
@@ -112,6 +113,7 @@ func TestBuilder_Initiator(t *testing.T) {
112113
withLastBuildFound,
113114
withRichParameters(nil),
114115
withParameterSchemas(inactiveJobID, nil),
116+
withWorkspaceTags(inactiveVersionID, nil),
115117

116118
// Outputs
117119
expectProvisionerJob(func(job database.InsertProvisionerJobParams) {
@@ -154,6 +156,7 @@ func TestBuilder_Baggage(t *testing.T) {
154156
withLastBuildFound,
155157
withRichParameters(nil),
156158
withParameterSchemas(inactiveJobID, nil),
159+
withWorkspaceTags(inactiveVersionID, nil),
157160

158161
// Outputs
159162
expectProvisionerJob(func(job database.InsertProvisionerJobParams) {
@@ -188,6 +191,7 @@ func TestBuilder_Reason(t *testing.T) {
188191
withLastBuildFound,
189192
withRichParameters(nil),
190193
withParameterSchemas(inactiveJobID, nil),
194+
withWorkspaceTags(inactiveVersionID, nil),
191195

192196
// Outputs
193197
expectProvisionerJob(func(job database.InsertProvisionerJobParams) {
@@ -813,6 +817,18 @@ func withRichParameters(params []database.WorkspaceBuildParameter) func(mTx *dbm
813817
}
814818
}
815819

820+
func withWorkspaceTags(versionID uuid.UUID, tags []database.TemplateVersionWorkspaceTag) func(mTx *dbmock.MockStore) {
821+
return func(mTx *dbmock.MockStore) {
822+
c := mTx.EXPECT().GetTemplateVersionWorkspaceTags(gomock.Any(), versionID).
823+
Times(1)
824+
if len(tags) > 0 {
825+
c.Return(tags, nil)
826+
} else {
827+
c.Return(nil, sql.ErrNoRows)
828+
}
829+
}
830+
}
831+
816832
// Since there is expected to be only one each of job, build, and build-parameters inserted, instead
817833
// of building matchers, we match any call and then assert its parameters. This will feel
818834
// more familiar to the way we write other tests.

0 commit comments

Comments
 (0)