Browse Source

modify case

dengwu12 8 years ago
parent
commit
455811bad2
1 changed files with 17 additions and 0 deletions
  1. 17 0
      oss/client_test.go

+ 17 - 0
oss/client_test.go

@@ -6,6 +6,7 @@ package oss
 
 
 import (
 import (
 	"log"
 	"log"
+	"math/rand"
 	"os"
 	"os"
 	"strings"
 	"strings"
 	"testing"
 	"testing"
@@ -56,8 +57,22 @@ var (
 	logPath        = "go_sdk_test_" + time.Now().Format("20060102_150405") + ".log"
 	logPath        = "go_sdk_test_" + time.Now().Format("20060102_150405") + ".log"
 	testLogFile, _ = os.OpenFile(logPath, os.O_RDWR|os.O_CREATE, 0664)
 	testLogFile, _ = os.OpenFile(logPath, os.O_RDWR|os.O_CREATE, 0664)
 	testLogger     = log.New(testLogFile, "", log.Ldate|log.Ltime|log.Lshortfile)
 	testLogger     = log.New(testLogFile, "", log.Ldate|log.Ltime|log.Lshortfile)
+	letters        = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
 )
 )
 
 
+func randStr(n int) string {
+	b := make([]rune, n)
+	r := rand.New(rand.NewSource(time.Now().UnixNano()))
+	for i := range b {
+		b[i] = letters[r.Intn(len(letters))]
+	}
+	return string(b)
+}
+
+func randLowStr(n int) string {
+	return strings.ToLower(randStr(n))
+}
+
 // Run once when the suite starts running
 // Run once when the suite starts running
 func (s *OssClientSuite) SetUpSuite(c *C) {
 func (s *OssClientSuite) SetUpSuite(c *C) {
 	client, err := New(endpoint, accessID, accessKey)
 	client, err := New(endpoint, accessID, accessKey)
@@ -191,6 +206,7 @@ func (s *OssClientSuite) TestCreateBucket(c *C) {
 
 
 	// create bucket with config and test get bucket info
 	// create bucket with config and test get bucket info
 	for _, storage := range []StorageClassType{StorageStandard, StorageIA, StorageArchive} {
 	for _, storage := range []StorageClassType{StorageStandard, StorageIA, StorageArchive} {
+		bucketNameTest := bucketNamePrefix + randLowStr(5)
 		cbConfig := CreateBucketConfiguration{StorageClass: storage}
 		cbConfig := CreateBucketConfiguration{StorageClass: storage}
 		err = client.DoCreateBucket(bucketNameTest, cbConfig, ACL(ACLPublicRead))
 		err = client.DoCreateBucket(bucketNameTest, cbConfig, ACL(ACLPublicRead))
 		c.Assert(err, IsNil)
 		c.Assert(err, IsNil)
@@ -213,6 +229,7 @@ func (s *OssClientSuite) TestCreateBucket(c *C) {
 
 
 	// create bucket with config and test list bucket
 	// create bucket with config and test list bucket
 	for _, storage := range []StorageClassType{StorageStandard, StorageIA, StorageArchive} {
 	for _, storage := range []StorageClassType{StorageStandard, StorageIA, StorageArchive} {
+		bucketNameTest := bucketNamePrefix + randLowStr(5)
 		cbConfig := CreateBucketConfiguration{StorageClass: storage}
 		cbConfig := CreateBucketConfiguration{StorageClass: storage}
 		err = client.DoCreateBucket(bucketNameTest, cbConfig)
 		err = client.DoCreateBucket(bucketNameTest, cbConfig)
 		c.Assert(err, IsNil)
 		c.Assert(err, IsNil)