MCPcopy
hub / github.com/dnote/dnote / TestLocalMigration7_trash

Function TestLocalMigration7_trash

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

Source from the content-addressed store, hash-verified

673}
674
675func TestLocalMigration7_trash(t *testing.T) {
676 // set up
677 db := database.InitTestMemoryDBRaw(t, "./fixtures/local-7-pre-schema.sql")
678 ctx := context.InitTestCtxWithDB(t, db)
679
680 b1UUID := testutils.MustGenerateUUID(t)
681 database.MustExec(t, "inserting trash book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "trash")
682
683 // Execute
684 tx, err := db.Begin()
685 if err != nil {
686 t.Fatal(errors.Wrap(err, "beginning a transaction"))
687 }
688
689 err = lm7.run(ctx, tx)
690 if err != nil {
691 tx.Rollback()
692 t.Fatal(errors.Wrap(err, "failed to run"))
693 }
694
695 tx.Commit()
696
697 // Test
698 var b1Label string
699 var b1Dirty bool
700 database.MustScan(t, "scanning b1 label", db.QueryRow("SELECT label, dirty FROM books WHERE uuid = ?", b1UUID), &b1Label, &b1Dirty)
701 assert.Equal(t, b1Label, "trash (2)", "b1 label was not migrated")
702 assert.Equal(t, b1Dirty, true, "b1 was not marked dirty")
703}
704
705func TestLocalMigration7_conflicts(t *testing.T) {
706 // set up

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected