Close files so that tests pass on windows
This commit is contained in:
parent
79d14c00bc
commit
c3f1813f6e
@ -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()
|
||||
}
|
||||
|
||||
|
16
dau_test.go
16
dau_test.go
@ -80,7 +80,11 @@ func TestCheckPath(t *testing.T) {
|
||||
if !w.checkPath() {
|
||||
t.Error("checkPath failed?")
|
||||
}
|
||||
os.RemoveAll(dir)
|
||||
|
||||
err := os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
t.Fatalf("could not remove test dir: %v", err)
|
||||
}
|
||||
if w.checkPath() {
|
||||
t.Error("checkPath succeeded when shouldn't?")
|
||||
}
|
||||
@ -91,9 +95,11 @@ func createFileTree() string {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
os.Create(fmt.Sprintf("%s%c%s", dir, os.PathSeparator, "a.gif"))
|
||||
os.Create(fmt.Sprintf("%s%c%s", dir, os.PathSeparator, "a.jpg"))
|
||||
os.Create(fmt.Sprintf("%s%c%s", dir, os.PathSeparator, "a.png"))
|
||||
|
||||
f1, _ := os.Create(fmt.Sprintf("%s%c%s", dir, os.PathSeparator, "a.gif"))
|
||||
f2, _ := os.Create(fmt.Sprintf("%s%c%s", dir, os.PathSeparator, "a.jpg"))
|
||||
f3, _ := os.Create(fmt.Sprintf("%s%c%s", dir, os.PathSeparator, "a.png"))
|
||||
f1.Close()
|
||||
f2.Close()
|
||||
f3.Close()
|
||||
return dir
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user