MCPcopy Index your code
hub / github.com/dnote/dnote / TestMigrateToV2

Function TestMigrateToV2

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

Source from the content-addressed store, hash-verified

105}
106
107func 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
140func TestMigrateToV3(t *testing.T) {
141 // set up

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected