rgw/admin: add test for bucket creation date

This commit is contained in:
Peter Willis 2024-02-22 07:53:54 +00:00 committed by mergify[bot]
parent f9dc7c1dcf
commit 9531dd692a
1 changed files with 9 additions and 0 deletions

View File

@ -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)