Close files so that tests pass on windows

This commit is contained in:
2021-10-16 16:18:02 +10:30
parent 79d14c00bc
commit c3f1813f6e
2 changed files with 18 additions and 7 deletions

View File

@@ -10,10 +10,14 @@ func TestNoConfig(t *testing.T) {
c := ConfigService{}
c.ConfigFilename = emptyTempFile()
os.Remove(c.ConfigFilename)
err := os.Remove(c.ConfigFilename)
if err != nil {
t.Fatalf("could not remove file: %v", err)
}
defer os.Remove(c.ConfigFilename) // because we are about to create it
err := c.LoadOrInit()
err = c.LoadOrInit()
if err != nil {
t.Errorf("unexpected failure from load: %s", err)
}
@@ -84,6 +88,7 @@ func emptyTempFile() string {
if err != nil {
panic(err)
}
f.Close()
return f.Name()
}