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

Function TestMigrate

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

Source from the content-addressed store, hash-verified

34}
35
36func TestMigrate(t *testing.T) {
37 t.Parallel()
38
39 if testing.Short() {
40 t.SkipNow()
41 return
42 }
43
44 t.Run("Once", func(t *testing.T) {
45 t.Parallel()
46
47 db := testSQLDB(t)
48
49 err := migrations.Up(db)
50 require.NoError(t, err)
51 })
52
53 t.Run("Parallel", func(t *testing.T) {
54 t.Parallel()
55
56 db := testSQLDB(t)
57 eg := errgroup.Group{}
58
59 eg.Go(func() error {
60 return migrations.Up(db)
61 })
62 eg.Go(func() error {
63 return migrations.Up(db)
64 })
65
66 require.NoError(t, eg.Wait())
67 })
68
69 t.Run("Twice", func(t *testing.T) {
70 t.Parallel()
71
72 db := testSQLDB(t)
73
74 err := migrations.Up(db)
75 require.NoError(t, err)
76
77 err = migrations.Up(db)
78 require.NoError(t, err)
79 })
80
81 t.Run("UpDownUp", func(t *testing.T) {
82 t.Parallel()
83
84 db := testSQLDB(t)
85
86 err := migrations.Up(db)
87 require.NoError(t, err)
88
89 err = migrations.Down(db)
90 require.NoError(t, err)
91
92 err = migrations.Up(db)
93 require.NoError(t, err)

Callers

nothing calls this directly

Calls 7

UpFunction · 0.92
DownFunction · 0.92
SkipNowMethod · 0.80
GoMethod · 0.80
testSQLDBFunction · 0.70
RunMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected