(t *testing.T)
| 733 | } |
| 734 | |
| 735 | func 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 | |
| 770 | func TestLocalMigration8(t *testing.T) { |
| 771 | // set up |
nothing calls this directly
no test coverage detected