(t *testing.T)
| 105 | } |
| 106 | |
| 107 | func TestMigrateToV2(t *testing.T) { |
| 108 | ctx := setupEnv(t, "../tmp") |
| 109 | defer teardownEnv(t, ctx) |
| 110 | |
| 111 | testutils.CopyFixture(t, ctx, "./fixtures/legacy-2-pre-dnote.json", "dnote") |
| 112 | |
| 113 | // execute |
| 114 | if err := migrateToV2(ctx); err != nil { |
| 115 | t.Fatal(errors.Wrap(err, "Failed to migrate").Error()) |
| 116 | } |
| 117 | |
| 118 | // test |
| 119 | b := testutils.ReadFile(ctx, "dnote") |
| 120 | |
| 121 | var postDnote migrateToV2PostDnote |
| 122 | if err := json.Unmarshal(b, &postDnote); err != nil { |
| 123 | t.Fatal(errors.Wrap(err, "Failed to unmarshal the result into Dnote").Error()) |
| 124 | } |
| 125 | |
| 126 | for _, book := range postDnote { |
| 127 | assert.NotEqual(t, book.Name, "", "Book name was not populated") |
| 128 | |
| 129 | for _, note := range book.Notes { |
| 130 | if len(note.UUID) == 8 { |
| 131 | t.Errorf("Note UUID was not migrated. It has length of %d", len(note.UUID)) |
| 132 | } |
| 133 | |
| 134 | assert.NotEqual(t, note.AddedOn, int64(0), "AddedOn was not carried over") |
| 135 | assert.Equal(t, note.EditedOn, int64(0), "EditedOn was not created properly") |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | func TestMigrateToV3(t *testing.T) { |
| 141 | // set up |
nothing calls this directly
no test coverage detected