Merge pull request #918 from harshavardhana/pr_out_add_tests_reported_by_go_coverage
Add tests reported by go coverage
This commit is contained in:
@@ -46,6 +46,10 @@ gomake-all: getdeps verifiers
|
||||
@go run make.go -install
|
||||
@mkdir -p $(HOME)/.mc
|
||||
|
||||
coverage:
|
||||
@go test -race -coverprofile=cover.out
|
||||
@go tool cover -html=cover.out && echo "Visit your browser"
|
||||
|
||||
release: getdeps verifiers
|
||||
@echo "Installing mc:"
|
||||
@go run make.go -release
|
||||
|
||||
@@ -47,9 +47,6 @@ func (b bucketACL) String() string {
|
||||
if !b.isValidBucketACL() {
|
||||
return string(b)
|
||||
}
|
||||
if b.isPrivate() {
|
||||
return "private"
|
||||
}
|
||||
if b.isReadOnly() {
|
||||
return "public-read"
|
||||
}
|
||||
|
||||
+3
-3
@@ -35,11 +35,11 @@ func isValidAliasName(aliasName string) bool {
|
||||
fallthrough
|
||||
case "private":
|
||||
fallthrough
|
||||
case "read-only":
|
||||
case "readonly":
|
||||
fallthrough
|
||||
case "public-read":
|
||||
case "public":
|
||||
fallthrough
|
||||
case "public-read-write":
|
||||
case "authenticated":
|
||||
return false
|
||||
}
|
||||
return validAliasName.MatchString(aliasName)
|
||||
|
||||
@@ -47,4 +47,8 @@ func (s *CmdTestSuite) TestCatCmd(c *C) {
|
||||
_, err = doCatCmd(sourceURL)
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
objectPath = filepath.Join(root, "object2")
|
||||
_, err = doCatCmd(objectPath)
|
||||
c.Assert(err, Not(IsNil))
|
||||
}
|
||||
|
||||
+54
-2
@@ -60,13 +60,33 @@ func (s *CmdTestSuite) SetUpSuite(c *C) {
|
||||
_, err = doConfig("generate", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
_, err = doConfig("generate", nil)
|
||||
c.Assert(err, Not(IsNil))
|
||||
|
||||
_, err = doConfig("cover", nil)
|
||||
c.Assert(err, Not(IsNil))
|
||||
|
||||
_, err = doConfig("alias", []string{"test", "https://test.io"})
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
_, err = doConfig("alias", []string{"test", "https://test.io"})
|
||||
c.Assert(err, Not(IsNil))
|
||||
|
||||
_, err = doConfig("alias", []string{"test", "htt://test.io"})
|
||||
c.Assert(err, Not(IsNil))
|
||||
|
||||
_, err = doConfig("alias", []string{"readonly", "https://new.test.io"})
|
||||
c.Assert(err, Not(IsNil))
|
||||
|
||||
objectAPI := objectAPIHandler(objectAPIHandler{lock: &sync.Mutex{}, bucket: "bucket", object: make(map[string][]byte)})
|
||||
server = httptest.NewServer(objectAPI)
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TearDownSuite(c *C) {
|
||||
os.RemoveAll(customConfigDir)
|
||||
server.Close()
|
||||
if server != nil {
|
||||
server.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestGetNewClient(c *C) {
|
||||
@@ -93,7 +113,7 @@ func (s *CmdTestSuite) TestNewConfigV1(c *C) {
|
||||
err = conf.Save(configFile)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
confNew := newConfigV1()
|
||||
confNew := newConfigV101()
|
||||
config, err := quick.New(confNew)
|
||||
c.Assert(err, IsNil)
|
||||
err = config.Load(configFile)
|
||||
@@ -126,6 +146,8 @@ func (s *CmdTestSuite) TestNewConfigV1(c *C) {
|
||||
}
|
||||
|
||||
wantHosts := []string{
|
||||
"localhost:*",
|
||||
"127.0.0.1:*",
|
||||
"play.minio.io:9000",
|
||||
"dl.minio.io:9000",
|
||||
"s3*.amazonaws.com",
|
||||
@@ -145,9 +167,39 @@ func (s *CmdTestSuite) TestRecursiveURL(c *C) {
|
||||
c.Assert(stripRecursiveURL("...url"), Equals, "...url")
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestHostConfig(c *C) {
|
||||
hostcfg, err := getHostConfig("https://s3.amazonaws.com")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(hostcfg.AccessKeyID, Equals, globalAccessKeyID)
|
||||
c.Assert(hostcfg.SecretAccessKey, Equals, globalSecretAccessKey)
|
||||
|
||||
_, err = getHostConfig("http://test.minio.io")
|
||||
c.Assert(err, Not(IsNil))
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestArgs2URL(c *C) {
|
||||
URLs := []string{"localhost:", "s3:", "play:", "https://s3-us-west-2.amazonaws.com"}
|
||||
expandedURLs, err := args2URLs(URLs)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(expandedURLs[0], Equals, "http://localhost:9000/")
|
||||
c.Assert(expandedURLs[1], Equals, "https://s3.amazonaws.com/")
|
||||
c.Assert(expandedURLs[2], Equals, "https://play.minio.io:9000/")
|
||||
c.Assert(expandedURLs[3], Equals, "https://s3-us-west-2.amazonaws.com")
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestValidACL(c *C) {
|
||||
acl := bucketACL("private")
|
||||
c.Assert(acl.isValidBucketACL(), Equals, true)
|
||||
c.Assert(acl.String(), Equals, "private")
|
||||
acl = bucketACL("public")
|
||||
c.Assert(acl.isValidBucketACL(), Equals, true)
|
||||
c.Assert(acl.String(), Equals, "public-read-write")
|
||||
acl = bucketACL("readonly")
|
||||
c.Assert(acl.isValidBucketACL(), Equals, true)
|
||||
c.Assert(acl.String(), Equals, "public-read")
|
||||
acl = bucketACL("authenticated")
|
||||
c.Assert(acl.isValidBucketACL(), Equals, true)
|
||||
c.Assert(acl.String(), Equals, "authenticated-read")
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestInvalidACL(c *C) {
|
||||
|
||||
Reference in New Issue
Block a user