Adding test function for getting config file
This commit is contained in:
@@ -58,6 +58,7 @@ func mustGetMcBashCompletionFilename() string {
|
||||
}
|
||||
|
||||
// NewClient - get new client
|
||||
// TODO refactor this to be more testable
|
||||
func getNewClient(debug bool, urlStr string) (clnt client.Client, err error) {
|
||||
hostCfg, err := getHostConfig(urlStr)
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
. "github.com/minio-io/check"
|
||||
"os/user"
|
||||
"path"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func (s *MySuite) TestGetMcConfigDir(c *C) {
|
||||
u, err := user.Current()
|
||||
c.Assert(err, IsNil)
|
||||
dir, err := getMcConfigDir()
|
||||
c.Assert(err, IsNil)
|
||||
if runtime.GOOS == "linux" {
|
||||
c.Assert(dir, Equals, path.Join(u.HomeDir, ".mc/"))
|
||||
} else if runtime.GOOS == "windows" {
|
||||
c.Assert(dir, Equals, path.Join(u.HomeDir, "mc/"))
|
||||
} else {
|
||||
c.Fail()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user