MCPcopy Index your code
hub / github.com/coder/coder / TestMigrateUpWithFixtures

Function TestMigrateUpWithFixtures

coderd/database/migrations/migrate_test.go:221–366  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

219}
220
221func TestMigrateUpWithFixtures(t *testing.T) {
222 t.Parallel()
223
224 if testing.Short() {
225 t.SkipNow()
226 return
227 }
228
229 type testCase struct {
230 name string
231 path string
232
233 // For determining if test case table stats
234 // are used to determine test coverage.
235 useStats bool
236 }
237 tests := []testCase{
238 {
239 name: "fixtures",
240 path: filepath.Join("testdata", "fixtures"),
241 useStats: true,
242 },
243 // More test cases added via glob below.
244 }
245
246 // Folders in testdata/full_dumps represent fixtures for a full
247 // deployment of Coder.
248 matches, err := filepath.Glob(filepath.Join("testdata", "full_dumps", "*"))
249 require.NoError(t, err)
250 for _, match := range matches {
251 tests = append(tests, testCase{
252 name: filepath.Base(match),
253 path: match,
254 useStats: true,
255 })
256 }
257
258 // These tables are allowed to have zero rows for now,
259 // but we should eventually add fixtures for them.
260 ignoredTablesForStats := []string{
261 "audit_logs",
262 "external_auth_links",
263 "group_members",
264 "licenses",
265 "replicas",
266 "template_version_parameters",
267 "workspace_build_parameters",
268 "template_version_variables",
269 "dbcrypt_keys", // having zero rows is a valid state for this table
270 "template_version_workspace_tags",
271 "notification_report_generator_logs",
272 }
273 s := &tableStats{s: make(map[string]int)}
274
275 // This will run after all subtests have run and fail the test if
276 // new tables have been added without covering them with fixtures.
277 t.Cleanup(func() {
278 emptyTables := s.Empty()

Callers

nothing calls this directly

Calls 15

EmptyMethod · 0.95
AddMethod · 0.95
DownFunction · 0.92
StepperFunction · 0.92
ContextFunction · 0.92
setupMigrateFunction · 0.85
SkipNowMethod · 0.80
LogMethod · 0.80
QueryRowContextMethod · 0.80
testSQLDBFunction · 0.70
CleanupMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected