Skip to content

Commit

Permalink
Improve testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sapk committed Mar 23, 2018
1 parent 7613a51 commit 43f453f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gluster/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
//MountTimeout timeout before killing a mount try in seconds
MountTimeout = 30
//CfgVersion current config version compat
CfgVersion = 2
CfgVersion = 1
//CfgFolder config folder
CfgFolder = "/etc/docker-volumes/gluster/"
)
Expand Down
30 changes: 25 additions & 5 deletions gluster/driver/driver_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
package driver

import (
"io/ioutil"
"log"
"os"
"testing"
)

func TestInit(t *testing.T) {
f, err := ioutil.TempDir("", "testing")
if err != nil {
log.Fatal(err)
}
defer os.RemoveAll(f) // clean up

CfgFolder = f

d := Init("/tmp/test-root", false)
if d == nil {
t.Error("Expected to be not null, got ", d)
}
/*
if _, err := os.Stat(cfgFolder + "gluster-persistence.json"); err != nil {
t.Error("Expected file to exist, got ", err)
}
*/
log.Println(d.Config)

d.SaveConfig()
//Second reload should reload parsistence file
d2 := Init("/tmp/test-root", false)
if d2 == nil {
t.Error("Expected to be not null, got ", d2)
}
log.Println(d2.Config)

if _, err := os.Stat(CfgFolder + "/persistence.json"); err != nil {
t.Error("Expected file to exist, got ", err)
}

}

0 comments on commit 43f453f

Please sign in to comment.