瀏覽代碼

add unit test while status of lifecycle rules is invalid

hangzws 6 年之前
父節點
當前提交
1868bd8019
共有 1 個文件被更改,包括 17 次插入4 次删除
  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,