MCPcopy
hub / github.com/dnote/dnote / TestLocalMigration12

Function TestLocalMigration12

pkg/cli/migrate/migrate_test.go:1022–1056  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1020}
1021
1022func TestLocalMigration12(t *testing.T) {
1023 // set up
1024 db := database.InitTestMemoryDBRaw(t, "./fixtures/local-12-pre-schema.sql")
1025 ctx := context.InitTestCtxWithDB(t, db)
1026
1027 data := []byte("editor: vim")
1028 path := fmt.Sprintf("%s/%s/dnoterc", ctx.Paths.Config, consts.DnoteDirName)
1029 if err := os.WriteFile(path, data, 0644); err != nil {
1030 t.Fatal(errors.Wrap(err, "Failed to write schema file"))
1031 }
1032
1033 // execute
1034 err := lm12.run(ctx, nil)
1035 if err != nil {
1036 t.Fatal(errors.Wrap(err, "failed to run"))
1037 }
1038
1039 // test
1040 b, err := os.ReadFile(path)
1041 if err != nil {
1042 t.Fatal(errors.Wrap(err, "reading config"))
1043 }
1044
1045 type config struct {
1046 APIEndpoint string `yaml:"apiEndpoint"`
1047 }
1048
1049 var cf config
1050 err = yaml.Unmarshal(b, &cf)
1051 if err != nil {
1052 t.Fatal(errors.Wrap(err, "unmarshalling config"))
1053 }
1054
1055 assert.NotEqual(t, cf.APIEndpoint, "", "apiEndpoint was not populated")
1056}
1057
1058func TestLocalMigration13(t *testing.T) {
1059 // set up

Callers

nothing calls this directly

Calls 3

InitTestMemoryDBRawFunction · 0.92
InitTestCtxWithDBFunction · 0.92
NotEqualFunction · 0.92

Tested by

no test coverage detected