(t *testing.T)
| 138 | } |
| 139 | |
| 140 | func TestMigrateToV3(t *testing.T) { |
| 141 | // set up |
| 142 | ctx := setupEnv(t, "../tmp") |
| 143 | defer teardownEnv(t, ctx) |
| 144 | |
| 145 | testutils.CopyFixture(t, ctx, "./fixtures/legacy-3-pre-dnote.json", "dnote") |
| 146 | |
| 147 | // execute |
| 148 | if err := migrateToV3(ctx); err != nil { |
| 149 | t.Fatal(errors.Wrap(err, "Failed to migrate").Error()) |
| 150 | } |
| 151 | |
| 152 | // test |
| 153 | b := testutils.ReadFile(ctx, "dnote") |
| 154 | var postDnote migrateToV3Dnote |
| 155 | if err := json.Unmarshal(b, &postDnote); err != nil { |
| 156 | t.Fatal(errors.Wrap(err, "Failed to unmarshal the result into Dnote").Error()) |
| 157 | } |
| 158 | |
| 159 | b = testutils.ReadFile(ctx, "actions") |
| 160 | var actions []migrateToV3Action |
| 161 | if err := json.Unmarshal(b, &actions); err != nil { |
| 162 | t.Fatal(errors.Wrap(err, "Failed to unmarshal the actions").Error()) |
| 163 | } |
| 164 | |
| 165 | assert.Equal(t, len(actions), 6, "actions length mismatch") |
| 166 | |
| 167 | for _, book := range postDnote { |
| 168 | for _, note := range book.Notes { |
| 169 | assert.NotEqual(t, note.AddedOn, int64(0), "AddedOn was not carried over") |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | func TestMigrateToV4(t *testing.T) { |
| 175 | // set up |
nothing calls this directly
no test coverage detected