Skip to content

Commit

Permalink
Add a test about message size exceeding
Browse files Browse the repository at this point in the history
  • Loading branch information
kojisaikiAtSony committed May 8, 2024
1 parent 9083ad0 commit 29dc396
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/gosqs/gosqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func init() {
app.SqsErrors["InvalidVisibilityTimeout"] = err8
err9 := app.SqsErrorType{HttpError: http.StatusBadRequest, Type: "MessageNotInFlight", Code: "AWS.SimpleQueueService.MessageNotInFlight", Message: "The message referred to isn't in flight."}
app.SqsErrors["MessageNotInFlight"] = err9
err10 := app.SqsErrorType{HttpError: http.StatusBadRequest, Type: "MessageTooBig", Code: "InvalidMessageContents", Message: "The message size exceeds the limit."}
err10 := app.SqsErrorType{HttpError: http.StatusBadRequest, Type: "MessageTooBig", Code: "InvalidParameterValue", Message: "The message size exceeds the limit."}
app.SqsErrors["MessageTooBig"] = err10
app.SqsErrors[ErrInvalidParameterValue.Type] = *ErrInvalidParameterValue
app.SqsErrors[ErrInvalidAttributeValue.Type] = *ErrInvalidAttributeValue
Expand Down
28 changes: 27 additions & 1 deletion smoke_tests/sqs_send_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,32 @@ func Test_SendMessageV1_json_with_attributes(t *testing.T) {
}

func Test_SendMessageV1_json_MaximumMessageSize_TooBig(t *testing.T) {
// TODO
server := generateServer()
defer func() {
server.Close()
utils.ResetResources()
}()

sdkConfig, _ := config.LoadDefaultConfig(context.TODO())
sdkConfig.BaseEndpoint = aws.String(server.URL)
sqsClient := sqs.NewFromConfig(sdkConfig)
sdkResponse, _ := sqsClient.CreateQueue(context.TODO(), &sqs.CreateQueueInput{
QueueName: &af.QueueName,
Attributes: map[string]string{
"MaximumMessageSize": "1",
},
})
targetQueueUrl := sdkResponse.QueueUrl

// Target test: send a message that is bigger than MaximumMessageSize
targetMessageBody := "Test_SendMessageV1_json_no_attributes"
sendMessageOutput, err := sqsClient.SendMessage(context.TODO(), &sqs.SendMessageInput{
QueueUrl: targetQueueUrl,
MessageBody: &targetMessageBody,
})
assert.Contains(t, err.Error(), "400")
assert.Contains(t, err.Error(), "InvalidParameterValue")
assert.Nil(t, sendMessageOutput)
}

func Test_SendMessageV1_json_QueueNotExistant(t *testing.T) {
Expand All @@ -190,5 +215,6 @@ func Test_SendMessageV1_json_QueueNotExistant(t *testing.T) {
MessageBody: &targetMessageBody,
})
assert.Contains(t, err.Error(), "400")
assert.Contains(t, err.Error(), "AWS.SimpleQueueService.NonExistentQueue")
assert.Nil(t, sendMessageOutput)
}

0 comments on commit 29dc396

Please sign in to comment.