MCPcopy
hub / github.com/dnote/dnote / TestLocalMigration6

Function TestLocalMigration6

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

Source from the content-addressed store, hash-verified

643}
644
645func TestLocalMigration6(t *testing.T) {
646 // set up
647 db := database.InitTestMemoryDBRaw(t, "./fixtures/local-5-pre-schema.sql")
648 ctx := context.InitTestCtxWithDB(t, db)
649
650 data := testutils.MustMarshalJSON(t, actions.AddBookDataV1{BookName: "js"})
651 a1UUID := testutils.MustGenerateUUID(t)
652 database.MustExec(t, "inserting action", db,
653 "INSERT INTO actions (uuid, schema, type, data, timestamp) VALUES (?, ?, ?, ?, ?)", a1UUID, 1, "add_book", string(data), 1537829463)
654
655 // Execute
656 tx, err := db.Begin()
657 if err != nil {
658 t.Fatal(errors.Wrap(err, "beginning a transaction"))
659 }
660
661 err = lm5.run(ctx, tx)
662 if err != nil {
663 tx.Rollback()
664 t.Fatal(errors.Wrap(err, "failed to run"))
665 }
666
667 tx.Commit()
668
669 // Test
670 var count int
671 err = db.QueryRow("SELECT name FROM sqlite_master WHERE type='table' AND name = ?;", "actions").Scan(&count)
672 assert.Equal(t, count, 0, "actions table should have been deleted")
673}
674
675func TestLocalMigration7_trash(t *testing.T) {
676 // set up

Callers

nothing calls this directly

Calls 10

InitTestMemoryDBRawFunction · 0.92
InitTestCtxWithDBFunction · 0.92
MustMarshalJSONFunction · 0.92
MustGenerateUUIDFunction · 0.92
MustExecFunction · 0.92
EqualFunction · 0.92
BeginMethod · 0.65
RollbackMethod · 0.65
CommitMethod · 0.65
QueryRowMethod · 0.65

Tested by

no test coverage detected