MCPcopy
hub / github.com/dnote/dnote / TestLocalMigration7_conflicts_dup

Function TestLocalMigration7_conflicts_dup

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

Source from the content-addressed store, hash-verified

733}
734
735func TestLocalMigration7_conflicts_dup(t *testing.T) {
736 // set up
737 db := database.InitTestMemoryDBRaw(t, "./fixtures/local-7-pre-schema.sql")
738 ctx := context.InitTestCtxWithDB(t, db)
739
740 b1UUID := testutils.MustGenerateUUID(t)
741 database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "conflicts")
742 b2UUID := testutils.MustGenerateUUID(t)
743 database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b2UUID, "conflicts (2)")
744
745 // Execute
746 tx, err := db.Begin()
747 if err != nil {
748 t.Fatal(errors.Wrap(err, "beginning a transaction"))
749 }
750
751 err = lm7.run(ctx, tx)
752 if err != nil {
753 tx.Rollback()
754 t.Fatal(errors.Wrap(err, "failed to run"))
755 }
756
757 tx.Commit()
758
759 // Test
760 var b1Label, b2Label string
761 var b1Dirty, b2Dirty bool
762 database.MustScan(t, "scanning b1 label", db.QueryRow("SELECT label, dirty FROM books WHERE uuid = ?", b1UUID), &b1Label, &b1Dirty)
763 database.MustScan(t, "scanning b2 label", db.QueryRow("SELECT label, dirty FROM books WHERE uuid = ?", b2UUID), &b2Label, &b2Dirty)
764 assert.Equal(t, b1Label, "conflicts (3)", "b1 label was not migrated")
765 assert.Equal(t, b2Label, "conflicts (2)", "b1 label was not migrated")
766 assert.Equal(t, b1Dirty, true, "b1 was not marked dirty")
767 assert.Equal(t, b2Dirty, false, "b2 should not have been marked dirty")
768}
769
770func TestLocalMigration8(t *testing.T) {
771 // 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