MCPcopy
hub / github.com/dnote/dnote / TestRun_up_to_date

Function TestRun_up_to_date

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

Source from the content-addressed store, hash-verified

244}
245
246func TestRun_up_to_date(t *testing.T) {
247 testCases := []struct {
248 mode int
249 schemaKey string
250 }{
251 {
252 mode: LocalMode,
253 schemaKey: consts.SystemSchema,
254 },
255 {
256 mode: RemoteMode,
257 schemaKey: consts.SystemRemoteSchema,
258 },
259 }
260
261 for _, tc := range testCases {
262 func() {
263 // set up
264 db := initTestDBNoMigration(t)
265 ctx := context.InitTestCtxWithDB(t, db)
266
267 database.MustExec(t, "creating a temporary table for testing", db,
268 "CREATE TABLE migrate_run_test ( name string )")
269
270 database.MustExec(t, "inserting a schema", db, "INSERT INTO system (key, value) VALUES (?, ?)", tc.schemaKey, 3)
271
272 sequence := []migration{
273 {
274 name: "v1",
275 run: func(ctx context.DnoteCtx, db *database.DB) error {
276 database.MustExec(t, "marking v1 completed", db, "INSERT INTO migrate_run_test (name) VALUES (?)", "v1")
277 return nil
278 },
279 },
280 {
281 name: "v2",
282 run: func(ctx context.DnoteCtx, db *database.DB) error {
283 database.MustExec(t, "marking v2 completed", db, "INSERT INTO migrate_run_test (name) VALUES (?)", "v2")
284 return nil
285 },
286 },
287 {
288 name: "v3",
289 run: func(ctx context.DnoteCtx, db *database.DB) error {
290 database.MustExec(t, "marking v3 completed", db, "INSERT INTO migrate_run_test (name) VALUES (?)", "v3")
291 return nil
292 },
293 },
294 }
295
296 // execute
297 err := Run(ctx, sequence, tc.mode)
298 if err != nil {
299 t.Fatal(errors.Wrap(err, "failed to run"))
300 }
301
302 // test
303 var schema int

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected