(t *testing.T)
| 831 | } |
| 832 | |
| 833 | func TestLocalMigration9(t *testing.T) { |
| 834 | // set up |
| 835 | db := database.InitTestMemoryDBRaw(t, "./fixtures/local-9-pre-schema.sql") |
| 836 | ctx := context.InitTestCtxWithDB(t, db) |
| 837 | |
| 838 | b1UUID := testutils.MustGenerateUUID(t) |
| 839 | database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1") |
| 840 | |
| 841 | n1UUID := testutils.MustGenerateUUID(t) |
| 842 | database.MustExec(t, "inserting n1", db, `INSERT INTO notes |
| 843 | (uuid, book_uuid, body, added_on, edited_on, public, dirty, usn, deleted) VALUES |
| 844 | (?, ?, ?, ?, ?, ?, ?, ?, ?)`, n1UUID, b1UUID, "n1 Body", 1, 2, true, true, 20, false) |
| 845 | n2UUID := testutils.MustGenerateUUID(t) |
| 846 | database.MustExec(t, "inserting n2", db, `INSERT INTO notes |
| 847 | (uuid, book_uuid, body, added_on, edited_on, public, dirty, usn, deleted) VALUES |
| 848 | (?, ?, ?, ?, ?, ?, ?, ?, ?)`, n2UUID, b1UUID, "n2 Body", 3, 4, false, true, 21, false) |
| 849 | |
| 850 | // Execute |
| 851 | tx, err := db.Begin() |
| 852 | if err != nil { |
| 853 | t.Fatal(errors.Wrap(err, "beginning a transaction")) |
| 854 | } |
| 855 | |
| 856 | err = lm9.run(ctx, tx) |
| 857 | if err != nil { |
| 858 | tx.Rollback() |
| 859 | t.Fatal(errors.Wrap(err, "failed to run")) |
| 860 | } |
| 861 | |
| 862 | tx.Commit() |
| 863 | |
| 864 | // Test |
| 865 | |
| 866 | // assert that note_fts was populated with correct values |
| 867 | var noteFtsCount int |
| 868 | database.MustScan(t, "counting note_fts", db.QueryRow("SELECT count(*) FROM note_fts;"), ¬eFtsCount) |
| 869 | assert.Equal(t, noteFtsCount, 2, "noteFtsCount mismatch") |
| 870 | |
| 871 | var resCount int |
| 872 | database.MustScan(t, "counting result", db.QueryRow("SELECT count(*) FROM note_fts WHERE note_fts MATCH ?", "n1"), &resCount) |
| 873 | assert.Equal(t, resCount, 1, "noteFtsCount mismatch") |
| 874 | } |
| 875 | |
| 876 | func TestLocalMigration10(t *testing.T) { |
| 877 | // set up |
nothing calls this directly
no test coverage detected