@@ -126,22 +126,22 @@ func TestClaimPrebuild(t *testing.T) {
126
126
ctx := testutil .Context (t , testutil .WaitSuperLong )
127
127
db , pubsub := dbtestutil .NewDB (t )
128
128
129
- wrappedStore := newStoreSpy (db , tc .storeError )
129
+ spy := newStoreSpy (db , tc .storeError )
130
130
expectedPrebuildsCount := desiredInstances * presetCount
131
131
132
132
logger := testutil .Logger (t )
133
133
client , _ , api , owner := coderdenttest .NewWithAPI (t , & coderdenttest.Options {
134
134
Options : & coderdtest.Options {
135
135
IncludeProvisionerDaemon : true ,
136
- Database : wrappedStore ,
136
+ Database : spy ,
137
137
Pubsub : pubsub ,
138
138
},
139
139
140
140
EntitlementsUpdateInterval : time .Second ,
141
141
})
142
142
143
- reconciler := prebuilds .NewStoreReconciler (wrappedStore , pubsub , codersdk.PrebuildsConfig {}, logger , quartz .NewMock (t ), prometheus .NewRegistry ())
144
- var claimer agplprebuilds.Claimer = prebuilds .NewEnterpriseClaimer (wrappedStore )
143
+ reconciler := prebuilds .NewStoreReconciler (spy , pubsub , codersdk.PrebuildsConfig {}, logger , quartz .NewMock (t ), prometheus .NewRegistry ())
144
+ var claimer agplprebuilds.Claimer = prebuilds .NewEnterpriseClaimer (spy )
145
145
api .AGPL .PrebuildsClaimer .Store (& claimer )
146
146
147
147
version := coderdtest .CreateTemplateVersion (t , client , owner .OrganizationID , templateWithAgentAndPresetsWithPrebuilds (desiredInstances ))
@@ -154,7 +154,7 @@ func TestClaimPrebuild(t *testing.T) {
154
154
userClient , user := coderdtest .CreateAnotherUser (t , client , owner .OrganizationID , rbac .RoleMember ())
155
155
156
156
// Given: the reconciliation state is snapshot.
157
- state , err := reconciler .SnapshotState (ctx , wrappedStore )
157
+ state , err := reconciler .SnapshotState (ctx , spy )
158
158
require .NoError (t , err )
159
159
require .Len (t , state .Presets , presetCount )
160
160
@@ -173,7 +173,7 @@ func TestClaimPrebuild(t *testing.T) {
173
173
// Given: a set of running, eligible prebuilds eventually starts up.
174
174
runningPrebuilds := make (map [uuid.UUID ]database.GetRunningPrebuiltWorkspacesRow , desiredInstances * presetCount )
175
175
require .Eventually (t , func () bool {
176
- rows , err := wrappedStore .GetRunningPrebuiltWorkspaces (ctx )
176
+ rows , err := spy .GetRunningPrebuiltWorkspaces (ctx )
177
177
if err != nil {
178
178
return false
179
179
}
@@ -228,7 +228,7 @@ func TestClaimPrebuild(t *testing.T) {
228
228
coderdtest .AwaitWorkspaceBuildJobCompleted (t , userClient , userWorkspace .LatestBuild .ID )
229
229
230
230
// Then: the number of running prebuilds hasn't changed because claiming prebuild is failed and we fallback to creating new workspace.
231
- currentPrebuilds , err := wrappedStore .GetRunningPrebuiltWorkspaces (ctx )
231
+ currentPrebuilds , err := spy .GetRunningPrebuiltWorkspaces (ctx )
232
232
require .NoError (t , err )
233
233
require .Equal (t , expectedPrebuildsCount , len (currentPrebuilds ))
234
234
return
@@ -239,7 +239,7 @@ func TestClaimPrebuild(t *testing.T) {
239
239
require .ErrorContains (t , err , unexpectedClaimingError .Error ())
240
240
241
241
// Then: the number of running prebuilds hasn't changed because claiming prebuild is failed.
242
- currentPrebuilds , err := wrappedStore .GetRunningPrebuiltWorkspaces (ctx )
242
+ currentPrebuilds , err := spy .GetRunningPrebuiltWorkspaces (ctx )
243
243
require .NoError (t , err )
244
244
require .Equal (t , expectedPrebuildsCount , len (currentPrebuilds ))
245
245
return
@@ -251,7 +251,6 @@ func TestClaimPrebuild(t *testing.T) {
251
251
}
252
252
253
253
// at this point we know that wrappedStore has *storeSpy type
254
- spy := wrappedStore
255
254
256
255
// Then: a prebuild should have been claimed.
257
256
require .EqualValues (t , spy .claims .Load (), 1 )
0 commit comments