diff --git a/events/attributevalue_test.go b/events/attributevalue_test.go index 2246b4d4..551c9d1c 100644 --- a/events/attributevalue_test.go +++ b/events/attributevalue_test.go @@ -211,6 +211,7 @@ func TestAccessWithWrongTypePanics(t *testing.T) { } for _, testCase := range testCases { + testCase := testCase var av DynamoDBAttributeValue err := json.Unmarshal([]byte(testCase.input), &av) assert.Nil(t, err) diff --git a/events/chime_bot_test.go b/events/chime_bot_test.go index 18598ba9..3caba67e 100644 --- a/events/chime_bot_test.go +++ b/events/chime_bot_test.go @@ -4,10 +4,10 @@ package events import ( "encoding/json" "testing" + "time" "github.com/aws/aws-lambda-go/events/test" "github.com/stretchr/testify/assert" - "time" ) func TestChimeBotEventMarshaling(t *testing.T) { @@ -116,6 +116,7 @@ func TestChimeBotEventMarshaling(t *testing.T) { } for name, test := range tests { + test := test t.Run(name, func(t *testing.T) { var testEvent ChimeBotEvent if err := json.Unmarshal([]byte(test.inputJSON), &testEvent); err != nil { diff --git a/events/cloudwatch_logs_test.go b/events/cloudwatch_logs_test.go index 1d60902f..c808e394 100644 --- a/events/cloudwatch_logs_test.go +++ b/events/cloudwatch_logs_test.go @@ -25,6 +25,7 @@ func TestCloudwatchLogs(t *testing.T) { }, }, } { + test := test t.Run(test.name, func(t *testing.T) { inputJson := tst.ReadJSONFromFile(t, test.eventJson) @@ -71,6 +72,7 @@ func TestCloudwatchLogsParse(t *testing.T) { }, }, } { + test := test t.Run(test.name, func(t *testing.T) { inputJson := tst.ReadJSONFromFile(t, test.eventJson) diff --git a/events/code_commit_test.go b/events/code_commit_test.go index 6945dcbb..493971df 100644 --- a/events/code_commit_test.go +++ b/events/code_commit_test.go @@ -33,6 +33,7 @@ func TestCodeCommitReference(t *testing.T) { } for _, c := range cases { + c := c t.Run(c.Name, func(t *testing.T) { test.AssertJsonBytes(t, c.Input, &CodeCommitReference{}) }) @@ -69,6 +70,7 @@ func TestCodeCommitCodeCommit(t *testing.T) { } for _, c := range cases { + c := c t.Run(c.Name, func(t *testing.T) { test.AssertJsonBytes(t, c.Input, &CodeCommitCodeCommit{}) }) @@ -128,6 +130,7 @@ func TestCodeCommitRecord(t *testing.T) { } for _, c := range cases { + c := c t.Run(c.Name, func(t *testing.T) { test.AssertJsonBytes(t, c.Input, &CodeCommitRecord{}) }) @@ -150,6 +153,7 @@ func TestCodeCommitEvent(t *testing.T) { } for _, c := range cases { + c := c t.Run(c.Name, func(t *testing.T) { test.AssertJsonBytes(t, c.Input, &CodeCommitEvent{}) }) diff --git a/events/ses_test.go b/events/ses_test.go index 41f9a523..d0da6c7a 100644 --- a/events/ses_test.go +++ b/events/ses_test.go @@ -19,6 +19,7 @@ func TestSESEventMarshaling(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.file, func(t *testing.T) { inputJSON := test.ReadJSONFromFile(t, tc.file) diff --git a/lambda/handler_test.go b/lambda/handler_test.go index 962ac38c..18d9163d 100644 --- a/lambda/handler_test.go +++ b/lambda/handler_test.go @@ -72,6 +72,7 @@ func TestInvalidHandlers(t *testing.T) { }, } for i, testCase := range testCases { + testCase := testCase t.Run(fmt.Sprintf("testCase[%d] %s", i, testCase.name), func(t *testing.T) { lambdaHandler := NewHandler(testCase.handler) _, err := lambdaHandler.Invoke(context.TODO(), make([]byte, 0)) @@ -188,6 +189,7 @@ func TestInvokes(t *testing.T) { }, } for i, testCase := range testCases { + testCase := testCase t.Run(fmt.Sprintf("testCase[%d] %s", i, testCase.name), func(t *testing.T) { lambdaHandler := NewHandler(testCase.handler) response, err := lambdaHandler.Invoke(context.TODO(), []byte(testCase.input))