From 9531dd692a3a60355cdcff9e4ea568fe06e8cf77 Mon Sep 17 00:00:00 2001 From: Peter Willis Date: Thu, 22 Feb 2024 07:53:54 +0000 Subject: [PATCH] rgw/admin: add test for bucket creation date --- rgw/admin/bucket_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rgw/admin/bucket_test.go b/rgw/admin/bucket_test.go index 46ee723..15b39ba 100644 --- a/rgw/admin/bucket_test.go +++ b/rgw/admin/bucket_test.go @@ -5,6 +5,7 @@ import ( "errors" "net/http" "testing" + "time" "github.com/ceph/go-ceph/internal/util" "github.com/stretchr/testify/assert" @@ -18,6 +19,7 @@ func (suite *RadosGWTestSuite) TestBucket() { s3, err := newS3Agent(suite.accessKey, suite.secretKey, suite.endpoint, true) assert.NoError(suite.T(), err) + beforeCreate := time.Now() err = s3.createBucket(suite.bucketTestName) assert.NoError(suite.T(), err) @@ -38,6 +40,13 @@ func (suite *RadosGWTestSuite) TestBucket() { assert.NoError(suite.T(), err) }) + suite.T().Run("existing bucket has valid creation date", func(_ *testing.T) { + b, err := co.GetBucketInfo(context.Background(), Bucket{Bucket: suite.bucketTestName}) + assert.NoError(suite.T(), err) + assert.NotNil(suite.T(), b.CreationTime) + assert.WithinDuration(suite.T(), beforeCreate, *b.CreationTime, time.Minute) + }) + suite.T().Run("get policy non-existing bucket", func(_ *testing.T) { _, err := co.GetBucketPolicy(context.Background(), Bucket{Bucket: "foo"}) assert.Error(suite.T(), err)