Adding config test

This commit is contained in:
Frederick F. Kautz IV
2015-04-11 16:05:32 -07:00
parent 954952a49d
commit 63a0ab89fe
2 changed files with 20 additions and 0 deletions
+6
View File
@@ -63,6 +63,12 @@ func getMcConfigDir() (string, error) {
return path.Join(u.HomeDir, mcConfigDir), nil
}
}
func mustGetMcConfigDir() string {
p, _ := getMcConfigDir()
return p
}
func getOrCreateMcConfigDir() (string, error) {
p, err := getMcConfigDir()
if err != nil {
+14
View File
@@ -19,4 +19,18 @@ func (s *MySuite) TestGetMcConfigDir(c *C) {
} else {
c.Fail()
}
c.Assert(mustGetMcConfigDir(), Equals, dir)
}
func (s *MySuite) TestGetMcConfigPath(c *C) {
dir, err := getMcConfigPath()
c.Assert(err, IsNil)
if runtime.GOOS == "linux" {
c.Assert(dir, Equals, path.Join(mustGetMcConfigDir(), "config.json"))
} else if runtime.GOOS == "windows" {
c.Assert(dir, Equals, path.Join(mustGetMcConfigDir(), "config.json"))
} else {
c.Fail()
}
c.Assert(mustGetMcConfigPath(), Equals, dir)
}