Explorar o código

add unit test while status of lifecycle rules is invalid

hangzws %!s(int64=6) %!d(string=hai) anos
pai
achega
1868bd8019
Modificáronse 1 ficheiros con 17 adicións e 4 borrados
  1. 17 4
      oss/client_test.go

+ 17 - 4
oss/client_test.go

@@ -665,21 +665,34 @@ func (s *OssClientSuite) TestSetBucketLifecycleNew(c *C) {
 	err = client.CreateBucket(bucketNameTest)
 	c.Assert(err, IsNil)
 
-	//invalid value of CreatedBeforeDate
+	//invalid status of lifecyclerule
 	expiration := LifecycleExpiration{
-		CreatedBeforeDate: randStr(10),
+		Days: 30,
 	}
 	rule := LifecycleRule{
 		ID:         "rule1",
 		Prefix:     "one",
-		Status:     "Enabled",
+		Status:     "Invalid",
 		Expiration: &expiration,
 	}
-	c.Assert(err, IsNil)
 	rules := []LifecycleRule{rule}
 	err = client.SetBucketLifecycle(bucketNameTest, rules)
 	c.Assert(err, NotNil)
 
+	//invalid value of CreatedBeforeDate
+	expiration = LifecycleExpiration{
+		CreatedBeforeDate: randStr(10),
+	}
+	rule = LifecycleRule{
+		ID:         "rule1",
+		Prefix:     "one",
+		Status:     "Enabled",
+		Expiration: &expiration,
+	}
+	rules = []LifecycleRule{rule}
+	err = client.SetBucketLifecycle(bucketNameTest, rules)
+	c.Assert(err, NotNil)
+
 	//invalid value of Days
 	abortMPU := LifecycleAbortMultipartUpload{
 		Days: -30,