Skip to content

Commit

Permalink
rgw/admin: add test for bucket creation date
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwillis authored and phlogistonjohn committed May 20, 2024
1 parent b431e3c commit 4ea4be1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rgw/admin/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"net/http"
"testing"
"time"

"github.com/ceph/go-ceph/internal/util"
"github.com/stretchr/testify/assert"
Expand All @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit 4ea4be1

Please sign in to comment.