(t *testing.T)
| 45 | } |
| 46 | |
| 47 | func TestExecute_bump_schema(t *testing.T) { |
| 48 | testCases := []struct { |
| 49 | schemaKey string |
| 50 | }{ |
| 51 | { |
| 52 | schemaKey: consts.SystemSchema, |
| 53 | }, |
| 54 | { |
| 55 | schemaKey: consts.SystemRemoteSchema, |
| 56 | }, |
| 57 | } |
| 58 | |
| 59 | for _, tc := range testCases { |
| 60 | func() { |
| 61 | // set up |
| 62 | db := initTestDBNoMigration(t) |
| 63 | ctx := context.InitTestCtxWithDB(t, db) |
| 64 | |
| 65 | database.MustExec(t, "inserting a schema", db, "INSERT INTO system (key, value) VALUES (?, ?)", tc.schemaKey, 8) |
| 66 | |
| 67 | m1 := migration{ |
| 68 | name: "noop", |
| 69 | run: func(ctx context.DnoteCtx, db *database.DB) error { |
| 70 | return nil |
| 71 | }, |
| 72 | } |
| 73 | m2 := migration{ |
| 74 | name: "noop", |
| 75 | run: func(ctx context.DnoteCtx, db *database.DB) error { |
| 76 | return nil |
| 77 | }, |
| 78 | } |
| 79 | |
| 80 | // execute |
| 81 | err := execute(ctx, m1, tc.schemaKey) |
| 82 | if err != nil { |
| 83 | t.Fatal(errors.Wrap(err, "failed to execute")) |
| 84 | } |
| 85 | err = execute(ctx, m2, tc.schemaKey) |
| 86 | if err != nil { |
| 87 | t.Fatal(errors.Wrap(err, "failed to execute")) |
| 88 | } |
| 89 | |
| 90 | // test |
| 91 | var schema int |
| 92 | database.MustScan(t, "getting schema", db.QueryRow("SELECT value FROM system WHERE key = ?", tc.schemaKey), &schema) |
| 93 | assert.Equal(t, schema, 10, "schema was not incremented properly") |
| 94 | }() |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | func TestRun_nonfresh(t *testing.T) { |
| 99 | testCases := []struct { |
nothing calls this directly
no test coverage detected