MCPcopy
hub / github.com/dnote/dnote / TestMigrateToV3

Function TestMigrateToV3

pkg/cli/migrate/legacy_test.go:140–172  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

138}
139
140func 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
174func TestMigrateToV4(t *testing.T) {
175 // set up

Callers

nothing calls this directly

Calls 8

CopyFixtureFunction · 0.92
ReadFileFunction · 0.92
EqualFunction · 0.92
NotEqualFunction · 0.92
setupEnvFunction · 0.85
teardownEnvFunction · 0.85
migrateToV3Function · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected