(t *testing.T)
| 96 | } |
| 97 | |
| 98 | func TestRun_nonfresh(t *testing.T) { |
| 99 | testCases := []struct { |
| 100 | mode int |
| 101 | schemaKey string |
| 102 | }{ |
| 103 | { |
| 104 | mode: LocalMode, |
| 105 | schemaKey: consts.SystemSchema, |
| 106 | }, |
| 107 | { |
| 108 | mode: RemoteMode, |
| 109 | schemaKey: consts.SystemRemoteSchema, |
| 110 | }, |
| 111 | } |
| 112 | |
| 113 | for _, tc := range testCases { |
| 114 | func() { |
| 115 | // set up |
| 116 | db := initTestDBNoMigration(t) |
| 117 | ctx := context.InitTestCtxWithDB(t, db) |
| 118 | database.MustExec(t, "inserting a schema", db, "INSERT INTO system (key, value) VALUES (?, ?)", tc.schemaKey, 2) |
| 119 | database.MustExec(t, "creating a temporary table for testing", db, |
| 120 | "CREATE TABLE migrate_run_test ( name string )") |
| 121 | |
| 122 | sequence := []migration{ |
| 123 | { |
| 124 | name: "v1", |
| 125 | run: func(ctx context.DnoteCtx, db *database.DB) error { |
| 126 | database.MustExec(t, "marking v1 completed", db, "INSERT INTO migrate_run_test (name) VALUES (?)", "v1") |
| 127 | return nil |
| 128 | }, |
| 129 | }, |
| 130 | { |
| 131 | name: "v2", |
| 132 | run: func(ctx context.DnoteCtx, db *database.DB) error { |
| 133 | database.MustExec(t, "marking v2 completed", db, "INSERT INTO migrate_run_test (name) VALUES (?)", "v2") |
| 134 | return nil |
| 135 | }, |
| 136 | }, |
| 137 | { |
| 138 | name: "v3", |
| 139 | run: func(ctx context.DnoteCtx, db *database.DB) error { |
| 140 | database.MustExec(t, "marking v3 completed", db, "INSERT INTO migrate_run_test (name) VALUES (?)", "v3") |
| 141 | return nil |
| 142 | }, |
| 143 | }, |
| 144 | { |
| 145 | name: "v4", |
| 146 | run: func(ctx context.DnoteCtx, db *database.DB) error { |
| 147 | database.MustExec(t, "marking v4 completed", db, "INSERT INTO migrate_run_test (name) VALUES (?)", "v4") |
| 148 | return nil |
| 149 | }, |
| 150 | }, |
| 151 | } |
| 152 | |
| 153 | // execute |
| 154 | err := Run(ctx, sequence, tc.mode) |
| 155 | if err != nil { |
nothing calls this directly
no test coverage detected