-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit tests for dynamomq errors
- Loading branch information
Showing
2 changed files
with
39 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dynamomq_test | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
. "github.com/vvatanabe/dynamomq" | ||
) | ||
|
||
func TestErrors(t *testing.T) { | ||
type testCase struct { | ||
err error | ||
expected string | ||
} | ||
tests := []testCase{ | ||
{IDNotProvidedError{}, "ID was not provided."}, | ||
{IDNotFoundError{}, "Provided ID was not found in the Dynamo DB."}, | ||
{IDDuplicatedError{}, "Provided ID was duplicated."}, | ||
{ConditionalCheckFailedError{Cause: errors.New("sample cause")}, "Condition on the 'version' attribute has failed: sample cause."}, | ||
{BuildingExpressionError{Cause: errors.New("sample cause")}, "Failed to build expression: sample cause."}, | ||
{DynamoDBAPIError{Cause: errors.New("sample cause")}, "Failed DynamoDB API: sample cause."}, | ||
{UnmarshalingAttributeError{Cause: errors.New("sample cause")}, "Failed to unmarshal: sample cause."}, | ||
{MarshalingAttributeError{Cause: errors.New("sample cause")}, "Failed to marshal: sample cause."}, | ||
{EmptyQueueError{}, "Cannot proceed, queue is empty."}, | ||
{InvalidStateTransitionError{Msg: "sample message", Operation: "sample operation", Current: "sample status"}, "operation sample operation failed for status sample status: sample message."}, | ||
} | ||
for _, tc := range tests { | ||
if tc.err.Error() != tc.expected { | ||
t.Errorf("Unexpected error message. Expected: %v, got: %v", tc.expected, tc.err.Error()) | ||
} | ||
} | ||
|
||
} |