-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathfatalerror_test.go
51 lines (42 loc) · 1.26 KB
/
fatalerror_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package fatalerror
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidRuntimeAndFunctionErrors(t *testing.T) {
type test struct {
input string
expected ErrorType
}
var tests = []test{}
for validError := range validRuntimeAndFunctionErrors {
tests = append(tests, test{input: string(validError), expected: validError})
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
assert.Equal(t, GetValidRuntimeOrFunctionErrorType(tt.input), tt.expected)
})
}
}
func TestGetValidRuntimeOrFunctionErrorType(t *testing.T) {
type test struct {
input string
expected ErrorType
}
var tests = []test{
{"", RuntimeUnknown},
{"MyCustomError", RuntimeUnknown},
{"MyCustomError.Error", RuntimeUnknown},
{"Runtime.MyCustomErrorTypeHere", ErrorType("Runtime.MyCustomErrorTypeHere")},
{"Function.MyCustomErrorTypeHere", ErrorType("Function.MyCustomErrorTypeHere")},
}
for _, tt := range tests {
testname := fmt.Sprintf("TestGetValidRuntimeOrFunctionErrorType with %s", tt.input)
t.Run(testname, func(t *testing.T) {
assert.Equal(t, GetValidRuntimeOrFunctionErrorType(tt.input), tt.expected)
})
}
}