diff --git a/cfn/event_test.go b/cfn/event_test.go index 9d22ad01..cc1c46cf 100644 --- a/cfn/event_test.go +++ b/cfn/event_test.go @@ -34,5 +34,5 @@ func TestCloudFormationEventMarshaling(t *testing.T) { } func TestCloudFormationMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, Event{}) + test.TestMalformedJson(t, &Event{}) } diff --git a/events/activemq_test.go b/events/activemq_test.go index 7b967893..5f04b597 100644 --- a/events/activemq_test.go +++ b/events/activemq_test.go @@ -43,5 +43,5 @@ func TestActiveMQEventMarshaling(t *testing.T) { } func TestActiveMQMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, ActiveMQEvent{}) + test.TestMalformedJson(t, &ActiveMQEvent{}) } diff --git a/events/alb_test.go b/events/alb_test.go index 56d5b963..b736b86b 100644 --- a/events/alb_test.go +++ b/events/alb_test.go @@ -37,7 +37,7 @@ func TestALBTargetRequestMarshaling(t *testing.T) { } func TestALBTargetRequestMalformedJson(t *testing.T) { - test.TestMalformedJson(t, ALBTargetGroupRequest{}) + test.TestMalformedJson(t, &ALBTargetGroupRequest{}) } func TestALBTargetResponseMarshaling(t *testing.T) { diff --git a/events/apigw_test.go b/events/apigw_test.go index 651718ab..89f568d9 100644 --- a/events/apigw_test.go +++ b/events/apigw_test.go @@ -57,7 +57,7 @@ func TestApiGatewayRequestMarshaling(t *testing.T) { } func TestApiGatewayRequestMalformedJson(t *testing.T) { - test.TestMalformedJson(t, APIGatewayProxyRequest{}) + test.TestMalformedJson(t, &APIGatewayProxyRequest{}) } func TestApiGatewayResponseMarshaling(t *testing.T) { @@ -84,7 +84,7 @@ func TestApiGatewayResponseMarshaling(t *testing.T) { } func TestApiGatewayResponseMalformedJson(t *testing.T) { - test.TestMalformedJson(t, APIGatewayProxyResponse{}) + test.TestMalformedJson(t, &APIGatewayProxyResponse{}) } func TestAPIGatewayProxyStreamingResponseMarshaling(t *testing.T) { @@ -208,11 +208,11 @@ func TestApiGatewayCustomAuthorizerRequestTypeRequestMarshaling(t *testing.T) { } func TestApiGatewayCustomAuthorizerRequestMalformedJson(t *testing.T) { - test.TestMalformedJson(t, APIGatewayCustomAuthorizerRequest{}) + test.TestMalformedJson(t, &APIGatewayCustomAuthorizerRequest{}) } func TestApiGatewayCustomAuthorizerRequestTypeRequestMalformedJson(t *testing.T) { - test.TestMalformedJson(t, APIGatewayCustomAuthorizerRequestTypeRequest{}) + test.TestMalformedJson(t, &APIGatewayCustomAuthorizerRequestTypeRequest{}) } func TestApiGatewayWebsocketRequestMarshaling(t *testing.T) { @@ -285,7 +285,7 @@ func TestApiGatewayWebsocketRequestDisconnectMarshaling(t *testing.T) { } func TestApiGatewayWebsocketRequestMalformedJson(t *testing.T) { - test.TestMalformedJson(t, APIGatewayWebsocketProxyRequest{}) + test.TestMalformedJson(t, &APIGatewayWebsocketProxyRequest{}) } func TestApiGatewayCustomAuthorizerResponseMarshaling(t *testing.T) { @@ -373,7 +373,7 @@ func TestAPIGatewayV2CustomAuthorizerSimpleResponseMarshalling(t *testing.T) { } func TestApiGatewayCustomAuthorizerResponseMalformedJson(t *testing.T) { - test.TestMalformedJson(t, APIGatewayCustomAuthorizerResponse{}) + test.TestMalformedJson(t, &APIGatewayCustomAuthorizerResponse{}) } func TestApiGatewayRestApiOpenApiRequestMarshaling(t *testing.T) { diff --git a/events/appsync_test.go b/events/appsync_test.go index 2e179261..3376a767 100644 --- a/events/appsync_test.go +++ b/events/appsync_test.go @@ -67,7 +67,7 @@ func TestAppSyncLambdaAuthorizerRequestMarshalling(t *testing.T) { } func TestAppSyncLambdaAuthorizerRequestMalformedJson(t *testing.T) { - test.TestMalformedJson(t, AppSyncLambdaAuthorizerRequest{}) + test.TestMalformedJson(t, &AppSyncLambdaAuthorizerRequest{}) } func TestAppSyncLambdaAuthorizerResponseMarshalling(t *testing.T) { @@ -90,5 +90,5 @@ func TestAppSyncLambdaAuthorizerResponseMarshalling(t *testing.T) { } func TestAppSyncLambdaAuthorizerResponseMalformedJson(t *testing.T) { - test.TestMalformedJson(t, AppSyncLambdaAuthorizerResponse{}) + test.TestMalformedJson(t, &AppSyncLambdaAuthorizerResponse{}) } diff --git a/events/autoscaling_test.go b/events/autoscaling_test.go index a41541d8..d5712037 100644 --- a/events/autoscaling_test.go +++ b/events/autoscaling_test.go @@ -37,5 +37,5 @@ func TestAutoScalingEventMarshaling(t *testing.T) { } func TestAutoScalingMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, AutoScalingEvent{}) + test.TestMalformedJson(t, &AutoScalingEvent{}) } diff --git a/events/chime_bot_test.go b/events/chime_bot_test.go index 3caba67e..e898ee32 100644 --- a/events/chime_bot_test.go +++ b/events/chime_bot_test.go @@ -135,5 +135,5 @@ func TestChimeBotEventMarshaling(t *testing.T) { } func TestChimeBotMarshalingMalformedJSON(t *testing.T) { - test.TestMalformedJson(t, ChimeBotEvent{}) + test.TestMalformedJson(t, &ChimeBotEvent{}) } diff --git a/events/clientvpn_test.go b/events/clientvpn_test.go index aae58d59..3d628184 100644 --- a/events/clientvpn_test.go +++ b/events/clientvpn_test.go @@ -32,5 +32,5 @@ func TestClientVPNConnectionHandlerRequestMarshaling(t *testing.T) { } func TestClientVPNConnectionHandlerRequestMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, ClientVPNConnectionHandlerRequest{}) + test.TestMalformedJson(t, &ClientVPNConnectionHandlerRequest{}) } diff --git a/events/cloudwatch_events_test.go b/events/cloudwatch_events_test.go index 3f49caba..c364bb86 100644 --- a/events/cloudwatch_events_test.go +++ b/events/cloudwatch_events_test.go @@ -32,5 +32,5 @@ func TestCloudwatchScheduledEventIdempotency(t *testing.T) { } func TestCloudwatchScheduledEventRequestMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CloudWatchEvent{}) + test.TestMalformedJson(t, &CloudWatchEvent{}) } diff --git a/events/codepipeline_job_test.go b/events/codepipeline_job_test.go index c78bfa0d..a4c98ef3 100644 --- a/events/codepipeline_job_test.go +++ b/events/codepipeline_job_test.go @@ -34,5 +34,5 @@ func TestCodePipeLineJobEventMarshaling(t *testing.T) { } func TestCodePipelineJobEventMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CodePipelineJobEvent{}) + test.TestMalformedJson(t, &CodePipelineJobEvent{}) } diff --git a/events/codepipeline_test.go b/events/codepipeline_test.go index cb7e0e6a..9d3e1f46 100644 --- a/events/codepipeline_test.go +++ b/events/codepipeline_test.go @@ -34,5 +34,5 @@ func TestCodePipeLineEventMarshaling(t *testing.T) { } func TestCodePipelineEventMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CodePipelineEvent{}) + test.TestMalformedJson(t, &CodePipelineEvent{}) } diff --git a/events/cognito_test.go b/events/cognito_test.go index 7a18e601..7da86f52 100644 --- a/events/cognito_test.go +++ b/events/cognito_test.go @@ -34,7 +34,7 @@ func TestCognitoEventMarshaling(t *testing.T) { } func TestCognitoMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEvent{}) + test.TestMalformedJson(t, &CognitoEvent{}) } func TestCognitoEventUserPoolsPreSignupMarshaling(t *testing.T) { @@ -61,7 +61,7 @@ func TestCognitoEventUserPoolsPreSignupMarshaling(t *testing.T) { } func TestCognitoUserPoolsPreSignupMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEventUserPoolsPreSignup{}) + test.TestMalformedJson(t, &CognitoEventUserPoolsPreSignup{}) } func TestCognitoEventUserPoolsPreAuthenticationMarshaling(t *testing.T) { @@ -88,7 +88,7 @@ func TestCognitoEventUserPoolsPreAuthenticationMarshaling(t *testing.T) { } func TestCognitoUserPoolsPreAuthenticationMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEventUserPoolsPreAuthentication{}) + test.TestMalformedJson(t, &CognitoEventUserPoolsPreAuthentication{}) } func TestCognitoEventUserPoolsPostConfirmationMarshaling(t *testing.T) { @@ -115,7 +115,7 @@ func TestCognitoEventUserPoolsPostConfirmationMarshaling(t *testing.T) { } func TestCognitoEventUserPoolsPreTokenGenMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEventUserPoolsPreTokenGen{}) + test.TestMalformedJson(t, &CognitoEventUserPoolsPreTokenGen{}) } func TestCognitoEventUserPoolsPreTokenGenMarshaling(t *testing.T) { @@ -190,7 +190,7 @@ func TestCognitoEventUserPoolsDefineAuthChallengeMarshaling(t *testing.T) { } func TestCognitoEventUserPoolsDefineAuthChallengeMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEventUserPoolsDefineAuthChallenge{}) + test.TestMalformedJson(t, &CognitoEventUserPoolsDefineAuthChallenge{}) } func TestCognitoEventUserPoolsCreateAuthChallengeMarshaling(t *testing.T) { @@ -199,7 +199,7 @@ func TestCognitoEventUserPoolsCreateAuthChallengeMarshaling(t *testing.T) { } func TestCognitoEventUserPoolsCreateAuthChallengeMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEventUserPoolsCreateAuthChallenge{}) + test.TestMalformedJson(t, &CognitoEventUserPoolsCreateAuthChallenge{}) } func TestCognitoEventUserPoolsVerifyAuthChallengeMarshaling(t *testing.T) { @@ -208,7 +208,7 @@ func TestCognitoEventUserPoolsVerifyAuthChallengeMarshaling(t *testing.T) { } func TestCognitoEventUserPoolsVerifyAuthChallengeMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEventUserPoolsVerifyAuthChallenge{}) + test.TestMalformedJson(t, &CognitoEventUserPoolsVerifyAuthChallenge{}) } func TestCognitoEventUserPoolsPostAuthenticationMarshaling(t *testing.T) { @@ -235,7 +235,7 @@ func TestCognitoEventUserPoolsPostAuthenticationMarshaling(t *testing.T) { } func TestCognitoEventUserPoolsMigrateUserMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEventUserPoolsMigrateUser{}) + test.TestMalformedJson(t, &CognitoEventUserPoolsMigrateUser{}) } func TestCognitoEventUserPoolsMigrateUserMarshaling(t *testing.T) { @@ -282,7 +282,7 @@ func TestCognitoEventUserPoolsCustomMessageMarshaling(t *testing.T) { } func TestCognitoUserPoolsCustomMessageMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEventUserPoolsCustomMessage{}) + test.TestMalformedJson(t, &CognitoEventUserPoolsCustomMessage{}) } func TestCognitoEventUserPoolsInboundFederationOIDCMarshaling(t *testing.T) { @@ -296,5 +296,5 @@ func TestCognitoEventUserPoolsInboundFederationSAMLMarshaling(t *testing.T) { } func TestCognitoEventUserPoolsInboundFederationMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, CognitoEventUserPoolsInboundFederation{}) + test.TestMalformedJson(t, &CognitoEventUserPoolsInboundFederation{}) } diff --git a/events/config_test.go b/events/config_test.go index 57b31123..ffae4e10 100644 --- a/events/config_test.go +++ b/events/config_test.go @@ -33,5 +33,5 @@ func TestConfigEventMarshaling(t *testing.T) { } func TestConfigMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, ConfigEvent{}) + test.TestMalformedJson(t, &ConfigEvent{}) } diff --git a/events/connect_test.go b/events/connect_test.go index 723f99f3..cc8dd748 100644 --- a/events/connect_test.go +++ b/events/connect_test.go @@ -32,5 +32,5 @@ func TestConnectMarshaling(t *testing.T) { } func TestConnectMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, ConnectEvent{}) + test.TestMalformedJson(t, &ConnectEvent{}) } diff --git a/events/dynamodb_test.go b/events/dynamodb_test.go index e364cb02..cce0d052 100644 --- a/events/dynamodb_test.go +++ b/events/dynamodb_test.go @@ -32,7 +32,7 @@ func TestDynamoDBEventMarshaling(t *testing.T) { } func TestDynamoDBEventMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, DynamoDBEvent{}) + test.TestMalformedJson(t, &DynamoDBEvent{}) } func TestDynamoDBTimeWindowEventMarshaling(t *testing.T) { @@ -56,5 +56,5 @@ func TestDynamoDBTimeWindowEventMarshaling(t *testing.T) { } func TestDynamoDBTimeWindowEventMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, DynamoDBTimeWindowEvent{}) + test.TestMalformedJson(t, &DynamoDBTimeWindowEvent{}) } diff --git a/events/ecr_image_action_test.go b/events/ecr_image_action_test.go index 180e8030..2177ff35 100644 --- a/events/ecr_image_action_test.go +++ b/events/ecr_image_action_test.go @@ -52,5 +52,5 @@ func TestECRImageActionEventMarshaling(t *testing.T) { } func TestECRPushMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, ECRImageActionEvent{}) + test.TestMalformedJson(t, &ECRImageActionEvent{}) } diff --git a/events/ecr_scan_test.go b/events/ecr_scan_test.go index 2029dbd5..a71f1895 100644 --- a/events/ecr_scan_test.go +++ b/events/ecr_scan_test.go @@ -52,5 +52,5 @@ func TestECRScanEventMarshaling(t *testing.T) { } func TestECRScanMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, ECRScanEvent{}) + test.TestMalformedJson(t, &ECRScanEvent{}) } diff --git a/events/ecs_container_instance_test.go b/events/ecs_container_instance_test.go index 1e7229ac..5c845eb2 100644 --- a/events/ecs_container_instance_test.go +++ b/events/ecs_container_instance_test.go @@ -90,5 +90,5 @@ func ptr(s string) *string { } func TestECSContainerInstanceMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, ECSContainerInstanceEvent{}) + test.TestMalformedJson(t, &ECSContainerInstanceEvent{}) } diff --git a/events/firehose_test.go b/events/firehose_test.go index 46409965..28d7ed5f 100644 --- a/events/firehose_test.go +++ b/events/firehose_test.go @@ -72,5 +72,5 @@ func toUpperHandler(ctx context.Context, evnt KinesisFirehoseEvent) KinesisFireh } func TestKinesisFirehoseMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, KinesisFirehoseEvent{}) + test.TestMalformedJson(t, &KinesisFirehoseEvent{}) } diff --git a/events/iot_1_click_test.go b/events/iot_1_click_test.go index 7f4ffc94..f91e4038 100644 --- a/events/iot_1_click_test.go +++ b/events/iot_1_click_test.go @@ -30,5 +30,5 @@ func TestIoTOneClickEventMalformedJson(t *testing.T) { } func TestIoTOneClickEventMarshaling(t *testing.T) { - test.TestMalformedJson(t, IoTOneClickEvent{}) + test.TestMalformedJson(t, &IoTOneClickEvent{}) } diff --git a/events/iot_button_test.go b/events/iot_button_test.go index 583cb43d..aa0671e6 100644 --- a/events/iot_button_test.go +++ b/events/iot_button_test.go @@ -30,5 +30,5 @@ func TestIoTButtonMalformedJson(t *testing.T) { } func TestIoTButtonEventMarshaling(t *testing.T) { - test.TestMalformedJson(t, IoTButtonEvent{}) + test.TestMalformedJson(t, &IoTButtonEvent{}) } diff --git a/events/iot_preprovision_hook_test.go b/events/iot_preprovision_hook_test.go index 09d7e490..7499bbb8 100644 --- a/events/iot_preprovision_hook_test.go +++ b/events/iot_preprovision_hook_test.go @@ -32,7 +32,7 @@ func TestIoTPreProvisionHookRequest(t *testing.T) { } func TestIoTPreProvisionHookRequestMalformedJson(t *testing.T) { - test.TestMalformedJson(t, IoTPreProvisionHookRequest{}) + test.TestMalformedJson(t, &IoTPreProvisionHookRequest{}) } func TestIoTPreProvisionHookResponseMarshaling(t *testing.T) { @@ -59,5 +59,5 @@ func TestIoTPreProvisionHookResponseMarshaling(t *testing.T) { } func TestIoTPreProvisionHookResponseMalformedJson(t *testing.T) { - test.TestMalformedJson(t, IoTPreProvisionHookResponse{}) + test.TestMalformedJson(t, &IoTPreProvisionHookResponse{}) } diff --git a/events/iot_test.go b/events/iot_test.go index 38cf84e9..eff948ca 100644 --- a/events/iot_test.go +++ b/events/iot_test.go @@ -32,7 +32,7 @@ func TestIoTCoreCustomAuthorizerRequestMarshaling(t *testing.T) { } func TestIoTCoreCustomAuthorizerRequestMalformedJson(t *testing.T) { - test.TestMalformedJson(t, IoTCoreCustomAuthorizerRequest{}) + test.TestMalformedJson(t, &IoTCoreCustomAuthorizerRequest{}) } func TestIoTCoreCustomAuthorizerResponseMarshaling(t *testing.T) { @@ -59,5 +59,5 @@ func TestIoTCoreCustomAuthorizerResponseMarshaling(t *testing.T) { } func TestIoTCoreCustomAuthorizerResponseMalformedJson(t *testing.T) { - test.TestMalformedJson(t, IoTCoreCustomAuthorizerResponse{}) + test.TestMalformedJson(t, &IoTCoreCustomAuthorizerResponse{}) } diff --git a/events/kafka_test.go b/events/kafka_test.go index f4ad6577..bc170dec 100644 --- a/events/kafka_test.go +++ b/events/kafka_test.go @@ -60,5 +60,5 @@ func TestKafkaEventMarshaling(t *testing.T) { } func TestKafkaMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, KafkaEvent{}) + test.TestMalformedJson(t, &KafkaEvent{}) } diff --git a/events/kinesis_analytics_test.go b/events/kinesis_analytics_test.go index 14e91fe1..5f9ce62f 100644 --- a/events/kinesis_analytics_test.go +++ b/events/kinesis_analytics_test.go @@ -18,7 +18,7 @@ func TestKinesisAnalyticsOutputDeliveryResponseMarshaling(t *testing.T) { } func TestKinesisOutputDeliveryEventMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, KinesisAnalyticsOutputDeliveryEvent{}) + test.TestMalformedJson(t, &KinesisAnalyticsOutputDeliveryEvent{}) } func testKinesisAnalyticsOutputMarshaling(t *testing.T, inputEvent interface{}, jsonFile string) { diff --git a/events/kinesis_test.go b/events/kinesis_test.go index 4ec2bbb1..5c96271f 100644 --- a/events/kinesis_test.go +++ b/events/kinesis_test.go @@ -31,7 +31,7 @@ func TestKinesisEventMarshaling(t *testing.T) { } func TestKinesisMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, KinesisEvent{}) + test.TestMalformedJson(t, &KinesisEvent{}) } func TestKinesisTimeWindowEventMarshaling(t *testing.T) { @@ -55,5 +55,5 @@ func TestKinesisTimeWindowEventMarshaling(t *testing.T) { } func TestKinesisTimeWindowEventMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, KinesisTimeWindowEvent{}) + test.TestMalformedJson(t, &KinesisTimeWindowEvent{}) } diff --git a/events/lex_test.go b/events/lex_test.go index efda78ef..afeea1dd 100644 --- a/events/lex_test.go +++ b/events/lex_test.go @@ -41,9 +41,9 @@ func TestLexResponseMarshaling(t *testing.T) { } func TestLexMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, LexEvent{}) + test.TestMalformedJson(t, &LexEvent{}) } func TestLexResponseMalformedJson(t *testing.T) { - test.TestMalformedJson(t, LexResponse{}) + test.TestMalformedJson(t, &LexResponse{}) } diff --git a/events/rabbitmq_test.go b/events/rabbitmq_test.go index 9935479f..b37d16ff 100644 --- a/events/rabbitmq_test.go +++ b/events/rabbitmq_test.go @@ -40,5 +40,5 @@ func TestRabbitMQEventMarshaling(t *testing.T) { } func TestRabbitMQMarshalingMalformedJSON(t *testing.T) { - test.TestMalformedJson(t, RabbitMQEvent{}) + test.TestMalformedJson(t, &RabbitMQEvent{}) } diff --git a/events/s3_object_lambda_test.go b/events/s3_object_lambda_test.go index 66e40ac7..0a65b843 100644 --- a/events/s3_object_lambda_test.go +++ b/events/s3_object_lambda_test.go @@ -40,5 +40,5 @@ func TestS3ObjectLambdaEventMarshaling(t *testing.T) { } func TestS3ObjectLambdaMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, S3ObjectLambdaEvent{}) + test.TestMalformedJson(t, &S3ObjectLambdaEvent{}) } diff --git a/events/s3_test.go b/events/s3_test.go index 8ec48fbf..979dac02 100644 --- a/events/s3_test.go +++ b/events/s3_test.go @@ -54,7 +54,7 @@ func TestS3TestEventMarshaling(t *testing.T) { } func TestS3MarshalingMalformedJSON(t *testing.T) { - test.TestMalformedJson(t, S3Event{}) + test.TestMalformedJson(t, &S3Event{}) } func TestS3GlacierEventMarshaling(t *testing.T) { diff --git a/events/ses_test.go b/events/ses_test.go index d0da6c7a..9537c983 100644 --- a/events/ses_test.go +++ b/events/ses_test.go @@ -39,5 +39,5 @@ func TestSESEventMarshaling(t *testing.T) { } func TestSESMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, SimpleEmailEvent{}) + test.TestMalformedJson(t, &SimpleEmailEvent{}) } diff --git a/events/sns_test.go b/events/sns_test.go index e084062c..4f0fe621 100644 --- a/events/sns_test.go +++ b/events/sns_test.go @@ -31,7 +31,7 @@ func TestSnsEventMarshaling(t *testing.T) { } func TestSnsMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, SNSEvent{}) + test.TestMalformedJson(t, &SNSEvent{}) } func TestCloudWatchAlarmSNSPayloadMarshaling(t *testing.T) { diff --git a/events/sqs_test.go b/events/sqs_test.go index b207d7b1..506ec035 100644 --- a/events/sqs_test.go +++ b/events/sqs_test.go @@ -31,5 +31,5 @@ func TestSqsEventMarshaling(t *testing.T) { } func TestSqsMarshalingMalformedJson(t *testing.T) { - test.TestMalformedJson(t, SQSEvent{}) + test.TestMalformedJson(t, &SQSEvent{}) } diff --git a/events/test/jsonsyntax.go b/events/test/jsonsyntax.go index a0d2b823..a734dff6 100644 --- a/events/test/jsonsyntax.go +++ b/events/test/jsonsyntax.go @@ -4,22 +4,27 @@ package test import ( "encoding/json" + "errors" "testing" ) +// unmarshalJSON is the function used by TestMalformedJson to deserialize JSON. +// It defaults to json.Unmarshal and can be overridden in tests within this package. +var unmarshalJSON = json.Unmarshal + // nolint: staticcheck -func TestMalformedJson(t *testing.T, objectToDeserialize interface{}) { +func TestMalformedJson(t testing.TB, objectToDeserialize interface{}) { // 1. read JSON from file inputJson := GetMalformedJson() // 2. de-serialize into Go object - err := json.Unmarshal(inputJson, objectToDeserialize) + err := unmarshalJSON(inputJson, objectToDeserialize) if err == nil { t.Errorf("unmarshal should have failed but succeeded instead") } - _, isSyntaxError := err.(*json.SyntaxError) - if !isSyntaxError { + var syntaxError *json.SyntaxError + if !errors.As(err, &syntaxError) { t.Errorf("unmarshal should have returned a json.SyntaxError") } } diff --git a/events/test/jsonsyntax_test.go b/events/test/jsonsyntax_test.go new file mode 100644 index 00000000..460bd6d9 --- /dev/null +++ b/events/test/jsonsyntax_test.go @@ -0,0 +1,84 @@ +// Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +package test + +import ( + "encoding/json" + "errors" + "testing" +) + +// mockTB implements testing.TB to capture Errorf calls. +type mockTB struct { + testing.TB + errors []string +} + +func (m *mockTB) Errorf(format string, args ...interface{}) { + m.errors = append(m.errors, format) +} + +func (m *mockTB) Helper() {} + +func TestMalformedJsonSyntaxError(t *testing.T) { + // Default behavior: malformed JSON produces json.SyntaxError, no Errorf called. + mock := &mockTB{} + target := make(map[string]interface{}) + TestMalformedJson(mock, &target) + + if len(mock.errors) != 0 { + t.Errorf("expected no errors, got: %v", mock.errors) + } +} + +func TestMalformedJsonUnmarshalSucceeds(t *testing.T) { + // When unmarshal unexpectedly returns nil, both Errorf calls should fire. + original := unmarshalJSON + unmarshalJSON = func([]byte, interface{}) error { + return nil + } + defer func() { unmarshalJSON = original }() + + mock := &mockTB{} + TestMalformedJson(mock, nil) + + if len(mock.errors) != 2 { + t.Fatalf("expected 2 errors, got %d: %v", len(mock.errors), mock.errors) + } + if mock.errors[0] != "unmarshal should have failed but succeeded instead" { + t.Errorf("unexpected first error message: %s", mock.errors[0]) + } + if mock.errors[1] != "unmarshal should have returned a json.SyntaxError" { + t.Errorf("unexpected second error message: %s", mock.errors[1]) + } +} + +func TestMalformedJsonNonSyntaxError(t *testing.T) { + // When unmarshal returns a non-SyntaxError, the second Errorf should fire. + original := unmarshalJSON + unmarshalJSON = func([]byte, interface{}) error { + return errors.New("some other error") + } + defer func() { unmarshalJSON = original }() + + mock := &mockTB{} + TestMalformedJson(mock, nil) + + if len(mock.errors) != 1 { + t.Fatalf("expected 1 error, got %d: %v", len(mock.errors), mock.errors) + } + if mock.errors[0] != "unmarshal should have returned a json.SyntaxError" { + t.Errorf("unexpected error message: %s", mock.errors[0]) + } +} + +func TestMalformedJsonDefaultUsesStdlib(t *testing.T) { + // Verify the default unmarshalJSON is json.Unmarshal. + mock := &mockTB{} + var target json.RawMessage + TestMalformedJson(mock, &target) + + if len(mock.errors) != 0 { + t.Errorf("expected no errors with default json.Unmarshal, got: %v", mock.errors) + } +} diff --git a/lambda/handler_test.go b/lambda/handler_test.go index bca7a30e..c3c91224 100644 --- a/lambda/handler_test.go +++ b/lambda/handler_test.go @@ -400,7 +400,7 @@ func TestInvokes(t *testing.T) { }, { name: "types that are not json serializable result in an error", - expected: expected{``, errors.New("json: error calling MarshalJSON for type struct { lambda.arbitraryJSON }: barf")}, + expected: expected{``, errors.New("json: error calling MarshalJSON")}, handler: func() (interface{}, error) { return struct { arbitraryJSON @@ -430,7 +430,7 @@ func TestInvokes(t *testing.T) { t.Run("via Handler.Invoke", func(t *testing.T) { response, err := lambdaHandler.Invoke(context.TODO(), []byte(testCase.input)) if testCase.expected.err != nil { - assert.EqualError(t, err, testCase.expected.err.Error()) + assert.ErrorContains(t, err, testCase.expected.err.Error()) } else { assert.NoError(t, err) assert.Equal(t, testCase.expected.val, string(response)) @@ -439,7 +439,7 @@ func TestInvokes(t *testing.T) { t.Run("via handlerOptions.handlerFunc", func(t *testing.T) { response, err := lambdaHandler.handlerFunc(context.TODO(), []byte(testCase.input)) if testCase.expected.err != nil { - assert.EqualError(t, err, testCase.expected.err.Error()) + assert.ErrorContains(t, err, testCase.expected.err.Error()) } else { assert.NoError(t, err) require.NotNil(t, response) diff --git a/lambda/invoke_loop_gte_go122_test.go b/lambda/invoke_loop_gte_go122_test.go index 83284562..b6b6f8d8 100644 --- a/lambda/invoke_loop_gte_go122_test.go +++ b/lambda/invoke_loop_gte_go122_test.go @@ -155,6 +155,13 @@ func TestConcurrencyWithRIE(t *testing.T) { handlerBuild.Env = append(os.Environ(), "GOOS=linux") require.NoError(t, handlerBuild.Run()) + // Pre-pull the container image so that pull latency doesn't count against + // the per-subtest readiness deadline. + pull := exec.Command(containerCmd, "pull", "public.ecr.aws/lambda/provided:al2023") + pull.Stdout = os.Stderr + pull.Stderr = os.Stderr + require.NoError(t, pull.Run()) + nInvokes := 10 concurrency := 3 sleepMs := 1000 @@ -189,7 +196,22 @@ func TestConcurrencyWithRIE(t *testing.T) { require.NoError(t, cmd.Start()) t.Cleanup(func() { _ = cmd.Process.Kill() }) - time.Sleep(5 * time.Second) // Wait for container to start and pull image if needed + // Poll until the container's RIE is accepting TCP connections. + const pollInterval = 100 * time.Millisecond + addr := fmt.Sprintf("127.0.0.1:%d", port) + deadline := time.Now().Add(30 * time.Second) + for time.Now().Before(deadline) { + conn, dialErr := net.DialTimeout("tcp", addr, pollInterval) + if dialErr == nil { + conn.Close() + break + } + time.Sleep(pollInterval) + } + + // Give the RIE a moment to fully initialize its HTTP handler after + // the TCP listener is up. + time.Sleep(500 * time.Millisecond) client := &http.Client{Timeout: 15 * time.Second} invokeURL := fmt.Sprintf("http://127.0.0.1:%d/2015-03-31/functions/function/invocations", port) diff --git a/lambda/invoke_loop_test.go b/lambda/invoke_loop_test.go index 4c305564..83888de2 100644 --- a/lambda/invoke_loop_test.go +++ b/lambda/invoke_loop_test.go @@ -437,8 +437,10 @@ func (invalidPayload) MarshalJSON() ([]byte, error) { func TestSafeMarshal_SerializationError(t *testing.T) { payload := safeMarshal(invalidPayload{}) - want := `{"errorMessage":"json: error calling MarshalJSON for type lambda.invalidPayload: some error that contains '\"'","errorType":"Runtime.SerializationError"}` - assert.Equal(t, want, string(payload)) + wantType := "Runtime.SerializationError" + wantPayload := "lambda.invalidPayload" + assert.Contains(t, string(payload), wantType) + assert.Contains(t, string(payload), wantPayload) } type requestRecord struct { diff --git a/lambda/sigterm_test.go b/lambda/sigterm_test.go index 5894ed16..2e276a80 100644 --- a/lambda/sigterm_test.go +++ b/lambda/sigterm_test.go @@ -37,6 +37,13 @@ func TestEnableSigterm(t *testing.T) { handlerBuild.Env = append(os.Environ(), "GOOS=linux") require.NoError(t, handlerBuild.Run()) + // Pre-pull the container image so that pull latency doesn't count against + // the per-subtest readiness deadline. + pull := exec.Command(containerCmd, "pull", "public.ecr.aws/lambda/provided:al2023") + pull.Stdout = os.Stderr + pull.Stderr = os.Stderr + require.NoError(t, pull.Run()) + for name, opts := range map[string]struct { envVars []string assertLogs func(t *testing.T, logs string) @@ -65,7 +72,7 @@ func TestEnableSigterm(t *testing.T) { cmdArgs := []string{"run", "--rm", "-v", testDir + ":/var/runtime:ro,delegated", "-p", fmt.Sprintf("%d:8080", port), - "-e", "AWS_LAMBDA_FUNCTION_TIMEOUT=2"} + "-e", "AWS_LAMBDA_FUNCTION_TIMEOUT=4"} for _, env := range opts.envVars { cmdArgs = append(cmdArgs, "-e", env) } @@ -87,19 +94,48 @@ func TestEnableSigterm(t *testing.T) { require.NoError(t, cmd.Start()) t.Cleanup(func() { _ = cmd.Process.Kill() }) - time.Sleep(5 * time.Second) // Wait for container to start + // Monitor the container process for early exit + cmdDone := make(chan error, 1) + go func() { + cmdDone <- cmd.Wait() + }() + + // Poll until the container's RIE is accepting TCP connections. + // We only do TCP dialing here — NOT HTTP requests — to avoid + // sending multiple requests, which can result in failures. + const pollInterval = 100 * time.Millisecond + addr := fmt.Sprintf("127.0.0.1:%d", port) + deadline := time.Now().Add(30 * time.Second) + for time.Now().Before(deadline) { + select { + case err := <-cmdDone: + <-logDone + require.Failf(t, "container exited before becoming ready", "exit error: %v\nlogs:\n%s", err, logBuf.String()) + default: + } + conn, dialErr := net.DialTimeout("tcp", addr, pollInterval) + if dialErr == nil { + conn.Close() + break + } + time.Sleep(pollInterval) + } + + // Give the RIE a moment to fully initialize its HTTP handler after + // the TCP listener is up. + time.Sleep(500 * time.Millisecond) - client := &http.Client{Timeout: 5 * time.Second} + client := &http.Client{Timeout: 10 * time.Second} invokeURL := fmt.Sprintf("http://127.0.0.1:%d/2015-03-31/functions/function/invocations", port) resp, err := client.Post(invokeURL, "application/json", strings.NewReader("{}")) require.NoError(t, err) defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) assert.NoError(t, err) - assert.Equal(t, "Task timed out after 2.00 seconds", string(body)) + assert.Equal(t, "Task timed out after 4.00 seconds", string(body)) _ = cmd.Process.Kill() - _ = cmd.Wait() + <-cmdDone <-logDone logs := logBuf.String()