Skip to content

Commit

Permalink
Merge pull request #381 from ekristen/fix-tests
Browse files Browse the repository at this point in the history
fix: tests
  • Loading branch information
ekristen authored Oct 14, 2024
2 parents 5d5a720 + b50f033 commit b9c675c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions resources/iam-user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func Test_IAMUser_Remove(t *testing.T) {

iamUser := IAMUser{
svc: svc,
name: aws.String("test-user"),
tags: createInput.Tags,
Name: aws.String("test-user"),
Tags: createInput.Tags,
}

removeError := iamUser.Remove(context.TODO())
Expand Down
26 changes: 20 additions & 6 deletions resources/s3-bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"
"time"

"github.com/gotidy/ptr"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

Expand All @@ -21,13 +22,13 @@ import (
"github.com/ekristen/aws-nuke/v3/pkg/awsmod"
)

type TestS3BucketObjectLockSuite struct {
type TestS3BucketSuite struct {
suite.Suite
bucket string
svc *s3.S3
}

func (suite *TestS3BucketObjectLockSuite) SetupSuite() {
func (suite *TestS3BucketSuite) SetupSuite() {
var err error

suite.bucket = fmt.Sprintf("aws-nuke-testing-bucket-%d", time.Now().UnixNano())
Expand Down Expand Up @@ -89,7 +90,7 @@ func (suite *TestS3BucketObjectLockSuite) SetupSuite() {
}
}

func (suite *TestS3BucketObjectLockSuite) TearDownSuite() {
func (suite *TestS3BucketSuite) TearDownSuite() {
iterator := newS3DeleteVersionListIterator(suite.svc, &s3.ListObjectVersionsInput{
Bucket: &suite.bucket,
}, true)
Expand Down Expand Up @@ -118,6 +119,10 @@ func (suite *TestS3BucketObjectLockSuite) TearDownSuite() {
}
}

type TestS3BucketObjectLockSuite struct {
TestS3BucketSuite
}

func (suite *TestS3BucketObjectLockSuite) TestS3BucketObjectLock() {
// Verify the object lock configuration
result, err := suite.svc.GetObjectLockConfiguration(&s3.GetObjectLockConfigurationInput{
Expand All @@ -144,11 +149,16 @@ func (suite *TestS3BucketObjectLockSuite) TestS3BucketRemove() {
assert.Error(suite.T(), err)
}

func (suite *TestS3BucketObjectLockSuite) TestS3BucketRemoveWithBypass() {
type TestS3BucketBypassGovernanceSuite struct {
TestS3BucketSuite
}

func (suite *TestS3BucketBypassGovernanceSuite) TestS3BucketRemoveWithBypass() {
// Create the S3Bucket object
bucket := &S3Bucket{
svc: suite.svc,
name: suite.bucket,
svc: suite.svc,
name: suite.bucket,
ObjectLock: ptr.String("Enabled"),
settings: &libsettings.Setting{
"BypassGovernanceRetention": true,
},
Expand All @@ -161,3 +171,7 @@ func (suite *TestS3BucketObjectLockSuite) TestS3BucketRemoveWithBypass() {
func TestS3BucketObjectLock(t *testing.T) {
suite.Run(t, new(TestS3BucketObjectLockSuite))
}

func TestS3BucketBypassGovernance(t *testing.T) {
suite.Run(t, new(TestS3BucketBypassGovernanceSuite))
}

0 comments on commit b9c675c

Please sign in to comment.