Skip to content

Commit

Permalink
Merge pull request #21 from mumoshu/failing-dbd-test
Browse files Browse the repository at this point in the history
Add failing-DynamoDB test
  • Loading branch information
cw-atkhry authored Oct 22, 2024
2 parents 0253439 + 5b1e1a1 commit 93948b3
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

type testcase struct {
setupS3 bool
setupDDB bool
setupSQS bool

okLabels []labels
Expand All @@ -35,6 +36,7 @@ func TestRun(t *testing.T) {
t.Run("ok", func(t *testing.T) {
checkRun(t, testcase{
setupS3: true,
setupDDB: true,
setupSQS: true,
okLabels: []labels{
{"S3", "GetObject", "Success"},
Expand All @@ -52,6 +54,7 @@ func TestRun(t *testing.T) {
t.Run("s3 failing", func(t *testing.T) {
checkRun(t, testcase{
setupS3: false,
setupDDB: true,
setupSQS: true,
okLabels: []labels{
{"S3", "GetObject", "Failure"},
Expand All @@ -69,6 +72,7 @@ func TestRun(t *testing.T) {
t.Run("sqs failing", func(t *testing.T) {
checkRun(t, testcase{
setupS3: true,
setupDDB: true,
setupSQS: false,
okLabels: []labels{
{"S3", "GetObject", "Success"},
Expand All @@ -82,6 +86,24 @@ func TestRun(t *testing.T) {
},
})
})

t.Run("DynamoDB failing", func(t *testing.T) {
checkRun(t, testcase{
setupS3: true,
setupDDB: false,
setupSQS: true,
okLabels: []labels{
{"S3", "GetObject", "Success"},
{"SQS", "ReceiveMessage", "Success"},
{"DynamoDB", "Scan", "Failure"},
},
ngLabels: []labels{
{"S3", "GetObject", "Failure"},
{"SQS", "ReceiveMessage", "Failure"},
{"DynamoDB", "Scan", "Success"},
},
})
})
}

func checkRun(t *testing.T, tc testcase) {
Expand All @@ -107,7 +129,9 @@ func checkRun(t *testing.T, tc testcase) {
setupS3BucketAndObject(t, ctx, awsConfig, s3EndpointResolver)
}

setupDynamoDBTable(t, ctx, awsConfig, dynamodbEndpointResolver)
if tc.setupDDB {
setupDynamoDBTable(t, ctx, awsConfig, dynamodbEndpointResolver)
}

if tc.setupSQS {
preservedQueueURL := os.Getenv("SQS_QUEUE_URL")
Expand Down

0 comments on commit 93948b3

Please sign in to comment.