MCPcopy
hub / github.com/dnote/dnote / TestExecute_bump_schema

Function TestExecute_bump_schema

pkg/cli/migrate/migrate_test.go:47–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func 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
98func TestRun_nonfresh(t *testing.T) {
99 testCases := []struct {

Callers

nothing calls this directly

Calls 7

InitTestCtxWithDBFunction · 0.92
MustExecFunction · 0.92
MustScanFunction · 0.92
EqualFunction · 0.92
initTestDBNoMigrationFunction · 0.85
executeFunction · 0.85
QueryRowMethod · 0.65

Tested by

no test coverage detected