(t *testing.T, ignoreLogErrors bool, ov *overrides)
| 5175 | } |
| 5176 | |
| 5177 | func setup(t *testing.T, ignoreLogErrors bool, ov *overrides) (proto.DRPCProvisionerDaemonServer, database.Store, pubsub.Pubsub, database.ProvisionerDaemon) { |
| 5178 | t.Helper() |
| 5179 | logger := testutil.Logger(t) |
| 5180 | db, ps := dbtestutil.NewDB(t) |
| 5181 | defOrg, err := db.GetDefaultOrganization(context.Background()) |
| 5182 | require.NoError(t, err, "default org not found") |
| 5183 | |
| 5184 | deploymentValues := coderdtest.DeploymentValues(t) |
| 5185 | var externalAuthConfigs []*externalauth.Config |
| 5186 | tss := testTemplateScheduleStore() |
| 5187 | uqhss := testUserQuietHoursScheduleStore() |
| 5188 | usageInserter := testUsageInserter() |
| 5189 | clock := quartz.NewReal() |
| 5190 | pollDur := time.Duration(0) |
| 5191 | if ov == nil { |
| 5192 | ov = &overrides{} |
| 5193 | } |
| 5194 | if ov.ctx == nil { |
| 5195 | ctx, cancel := context.WithCancel(dbauthz.AsProvisionerd(context.Background())) |
| 5196 | t.Cleanup(cancel) |
| 5197 | ov.ctx = ctx |
| 5198 | } |
| 5199 | if ov.heartbeatInterval == 0 { |
| 5200 | ov.heartbeatInterval = testutil.IntervalMedium |
| 5201 | } |
| 5202 | if ov.deploymentValues != nil { |
| 5203 | deploymentValues = ov.deploymentValues |
| 5204 | } |
| 5205 | if ov.externalAuthConfigs != nil { |
| 5206 | externalAuthConfigs = ov.externalAuthConfigs |
| 5207 | } |
| 5208 | if ov.templateScheduleStore != nil { |
| 5209 | ttss := tss.Load() |
| 5210 | // keep the initial test value if the override hasn't set the atomic pointer. |
| 5211 | tss = ov.templateScheduleStore |
| 5212 | if tss.Load() == nil { |
| 5213 | swapped := tss.CompareAndSwap(nil, ttss) |
| 5214 | require.True(t, swapped) |
| 5215 | } |
| 5216 | } |
| 5217 | if ov.userQuietHoursScheduleStore != nil { |
| 5218 | tuqhss := uqhss.Load() |
| 5219 | // keep the initial test value if the override hasn't set the atomic pointer. |
| 5220 | uqhss = ov.userQuietHoursScheduleStore |
| 5221 | if uqhss.Load() == nil { |
| 5222 | swapped := uqhss.CompareAndSwap(nil, tuqhss) |
| 5223 | require.True(t, swapped) |
| 5224 | } |
| 5225 | } |
| 5226 | if ov.usageInserter != nil { |
| 5227 | tUsageInserter := usageInserter.Load() |
| 5228 | // keep the initial test value if the override hasn't set the atomic pointer. |
| 5229 | usageInserter = ov.usageInserter |
| 5230 | if usageInserter.Load() == nil { |
| 5231 | swapped := usageInserter.CompareAndSwap(nil, tUsageInserter) |
| 5232 | require.True(t, swapped) |
| 5233 | } |
| 5234 | } |
no test coverage detected