diff --git a/cmd-config.go b/cmd-config.go index 05839e58..50148904 100644 --- a/cmd-config.go +++ b/cmd-config.go @@ -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 { diff --git a/cmd-config_test.go b/cmd-config_test.go index 2a391f13..80763c05 100644 --- a/cmd-config_test.go +++ b/cmd-config_test.go @@ -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) }