-
Notifications
You must be signed in to change notification settings - Fork 23
/
error_test.go
35 lines (29 loc) · 986 Bytes
/
error_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package rekognition
import (
"errors"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsErrorInvalidImageEncoding(t *testing.T) {
a := assert.New(t)
tests := []struct {
expected bool
text string
}{
{true, "InvalidImageFormatException: Invalid image encoding"},
{true, "status code: 400, request id: 00ff00ff-00ff-00ff-00ff-00ff00ff00ff, InvalidImageFormatException: Invalid image encoding"},
{true, "InvalidImageFormatException: Invalid image encoding, error"},
{true, "error, InvalidImageFormatException: Invalid image encoding, error"},
{false, "No errors"},
{false, "InvalidImageFormatException: Invalid image encodin"},
{false, "nvalidImageFormatException: Invalid image encoding"},
{false, ""},
}
for _, tt := range tests {
target := fmt.Sprintf("%+v", tt)
err := errors.New(tt.text)
a.Equal(tt.expected, IsErrorInvalidImageEncoding(err), target)
}
a.Equal(false, IsErrorInvalidImageEncoding(nil), "When error=nil")
}