MCPcopy
hub / github.com/dnote/dnote / TestLocalMigration7_conflicts

Function TestLocalMigration7_conflicts

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

Source from the content-addressed store, hash-verified

703}
704
705func TestLocalMigration7_conflicts(t *testing.T) {
706 // set up
707 db := database.InitTestMemoryDBRaw(t, "./fixtures/local-7-pre-schema.sql")
708 ctx := context.InitTestCtxWithDB(t, db)
709
710 b1UUID := testutils.MustGenerateUUID(t)
711 database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "conflicts")
712
713 // Execute
714 tx, err := db.Begin()
715 if err != nil {
716 t.Fatal(errors.Wrap(err, "beginning a transaction"))
717 }
718
719 err = lm7.run(ctx, tx)
720 if err != nil {
721 tx.Rollback()
722 t.Fatal(errors.Wrap(err, "failed to run"))
723 }
724
725 tx.Commit()
726
727 // Test
728 var b1Label string
729 var b1Dirty bool
730 database.MustScan(t, "scanning b1 label", db.QueryRow("SELECT label, dirty FROM books WHERE uuid = ?", b1UUID), &b1Label, &b1Dirty)
731 assert.Equal(t, b1Label, "conflicts (2)", "b1 label was not migrated")
732 assert.Equal(t, b1Dirty, true, "b1 was not marked dirty")
733}
734
735func TestLocalMigration7_conflicts_dup(t *testing.T) {
736 // 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