Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Shunpoco committed Jun 3, 2024
1 parent e6bfda9 commit 7fd1463
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions internal/rgw/lifecycleconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rgw
import (
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
awss3 "github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/aws/smithy-go/document"
Expand All @@ -18,6 +19,8 @@ func TestGenerateLifecycleConfigurationInput(t *testing.T) {
days90 := int32(90)
days365 := int32(365)
days3650 := int32(3650)
maxObjectSize := int64(100)
minObjectSize := int64(1)
t.Parallel()

type args struct {
Expand Down Expand Up @@ -175,6 +178,58 @@ func TestGenerateLifecycleConfigurationInput(t *testing.T) {
},
},
},
"Config with filters": {
args: args{
name: bucketname,
config: &v1alpha1.BucketLifecycleConfiguration{
Rules: []v1alpha1.LifecycleRule{
{
Status: "Enabled",
Expiration: &v1alpha1.LifecycleExpiration{
Days: &days365,
},
Filter: &v1alpha1.LifecycleRuleFilter{
And: &v1alpha1.LifecycleRuleAndOperator{
Prefix: &prefix,
Tags: []v1alpha1.Tag{
{Key: "key1", Value: "value1"},
{Key: "key2", Value: "value2"},
},
ObjectSizeGreaterThan: &maxObjectSize,
ObjectSizeLessThan: &minObjectSize,
},
},
},
},
},
},
want: want{
result: &awss3.PutBucketLifecycleConfigurationInput{
Bucket: &bucketname,
LifecycleConfiguration: &types.BucketLifecycleConfiguration{
Rules: []types.LifecycleRule{
{
Status: "Enabled",
Expiration: &types.LifecycleExpiration{
Days: &days365,
},
Filter: &types.LifecycleRuleFilterMemberAnd{
Value: types.LifecycleRuleAndOperator{
Prefix: &prefix,
Tags: []types.Tag{
{Key: aws.String("key1"), Value: aws.String("value1")},
{Key: aws.String("key2"), Value: aws.String("value2")},
},
ObjectSizeGreaterThan: &maxObjectSize,
ObjectSizeLessThan: &minObjectSize,
},
},
},
},
},
},
},
},
}
for name, tc := range cases {
tc := tc
Expand Down

0 comments on commit 7fd1463

Please sign in to comment.