diff --git a/cmd_test.go b/cmd_test.go index 23f662db..bbf6f906 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -17,6 +17,8 @@ package main import ( + "io/ioutil" + "os" "os/user" "path" "runtime" @@ -28,6 +30,7 @@ import ( "github.com/cheggaaa/pb" . "github.com/minio-io/check" + "github.com/minio-io/mc/pkg/quick" "github.com/minio-io/minio/pkg/iodine" ) @@ -42,6 +45,70 @@ func mustGetMcConfigDir() string { return dir } +func (s *CmdTestSuite) TestGetNewClient(c *C) { + _, err := getNewClient("http://example.com/bucket1", &hostConfig{}, false) + c.Assert(err, IsNil) + + _, err = getNewClient("file", &hostConfig{}, false) + c.Assert(err, IsNil) + + _, err = getNewClient("%", &hostConfig{}, false) + c.Assert(err, Not(IsNil)) +} + +func (s *CmdTestSuite) TestNewConfigV1(c *C) { + root, err := ioutil.TempDir(os.TempDir(), "mc-") + c.Assert(err, IsNil) + defer os.RemoveAll(root) + + conf := newConfig() + configFile := path.Join(root, "config.json") + err = conf.Save(configFile) + c.Assert(err, IsNil) + + confNew := newConfigV1() + config := quick.New(confNew) + err = config.Load(configFile) + c.Assert(err, IsNil) + data := config.Data().(*configV1) + + type aliases struct { + name string + url string + } + + want := []aliases{ + { + "s3", + "https://s3.amazonaws.com", + }, + { + "play", + "http://play.minio.io:9000", + }, + { + "localhost", + "http://localhost:9000", + }, + } + for _, alias := range want { + url, ok := data.Aliases[alias.name] + c.Assert(ok, Equals, true) + c.Assert(url, Equals, alias.url) + } + +} + +func (s *CmdTestSuite) TestValidACL(c *C) { + acl := bucketACL("private") + c.Assert(acl.isValidBucketACL(), Equals, true) +} + +func (s *CmdTestSuite) TestInvalidACL(c *C) { + acl := bucketACL("invalid") + c.Assert(acl.isValidBucketACL(), Equals, false) +} + func (s *CmdTestSuite) TestGetMcConfigDir(c *C) { u, err := user.Current() c.Assert(err, IsNil) diff --git a/clientmethods.go b/common-methods.go similarity index 100% rename from clientmethods.go rename to common-methods.go diff --git a/pkg/console/console.go b/pkg/console/console.go index e20adcd0..f0095b8b 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -29,7 +29,7 @@ import ( ) // NoDebugPrint defines if the input should be printed or not. By default it's set to true. -var NoDebugPrint bool = true +var NoDebugPrint = true var ( mutex = &sync.RWMutex{}