Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Jul 5, 2024
1 parent f631039 commit a810028
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/accumulated/run/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (c *Config) Save() error {
if c.file == "" {
return errors.BadRequest.With("not loaded from a file")
}
if c.fs != os.DirFS(".") {
if c.fs != nil && c.fs != os.DirFS(".") {
return errors.BadRequest.With("loaded from an immutable filesystem")
}
return c.SaveTo(c.file)
Expand Down
12 changes: 12 additions & 0 deletions cmd/accumulated/run/dotenv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ func TestDotenv(t *testing.T) {
})
}

func TestSaveToFS(t *testing.T) {
fs := mkfs(map[string]string{
"accumulate.toml": `network = "foo"`,
})

cfg := new(Config)
require.NoError(t, cfg.LoadFromFS(fs, "accumulate.toml"))

// Ensure Save doesn't panic when loaded from [fs.FS]
require.Error(t, cfg.Save())
}

func mkfs(files map[string]string) fs.FS {
root := new(testutil.Dir)
for name, data := range files {
Expand Down

0 comments on commit a810028

Please sign in to comment.