From 5b1e1a150943ac7aa55b807dfd164078a64899a1 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Tue, 22 Oct 2024 05:27:05 +0000 Subject: [PATCH] Add failing-DynamoDB test --- main_test.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/main_test.go b/main_test.go index 79dbb56..fe5a4da 100644 --- a/main_test.go +++ b/main_test.go @@ -25,6 +25,7 @@ import ( type testcase struct { setupS3 bool + setupDDB bool setupSQS bool okLabels []labels @@ -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"}, @@ -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"}, @@ -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"}, @@ -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) { @@ -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")