MCPcopy
hub / github.com/dnote/dnote / TestMigrateToV4

Function TestMigrateToV4

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

Source from the content-addressed store, hash-verified

172}
173
174func TestMigrateToV4(t *testing.T) {
175 // set up
176 ctx := setupEnv(t, "../tmp")
177 defer teardownEnv(t, ctx)
178 defer os.Setenv("EDITOR", "")
179
180 testutils.CopyFixture(t, ctx, "./fixtures/legacy-4-pre-dnoterc.yaml", "dnoterc")
181
182 // execute
183 os.Setenv("EDITOR", "vim")
184 if err := migrateToV4(ctx); err != nil {
185 t.Fatal(errors.Wrap(err, "Failed to migrate").Error())
186 }
187
188 // test
189 b := testutils.ReadFile(ctx, "dnoterc")
190 var config migrateToV4PostConfig
191 if err := yaml.Unmarshal(b, &config); err != nil {
192 t.Fatal(errors.Wrap(err, "Failed to unmarshal the result into Dnote").Error())
193 }
194
195 assert.Equal(t, config.APIKey, "Oev6e1082ORasdf9rjkfjkasdfjhgei", "api key mismatch")
196 assert.Equal(t, config.Editor, "vim", "editor mismatch")
197}
198
199func TestMigrateToV5(t *testing.T) {
200 // set up

Callers

nothing calls this directly

Calls 7

CopyFixtureFunction · 0.92
ReadFileFunction · 0.92
EqualFunction · 0.92
setupEnvFunction · 0.85
teardownEnvFunction · 0.85
migrateToV4Function · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected