-
Notifications
You must be signed in to change notification settings - Fork 4
/
sqs_client_config_test.go
102 lines (77 loc) · 2.11 KB
/
sqs_client_config_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package remoteconfig
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
const (
VALID_SQS_CLIENT_REGION AWSRegion = AWS_REGION_US_EAST_1
VALID_SQS_CLIENT_ENDPOINT string = "http://localhost/testsqs"
)
type SQSClientConfigSuite struct {
suite.Suite
}
func TestSQSClientConfigSuite(t *testing.T) {
suite.Run(t, new(SQSClientConfigSuite))
}
func (s *SQSClientConfigSuite) SetupSuite() {
}
func (s *SQSClientConfigSuite) SetupTest() {
}
func (s *SQSClientConfigSuite) TestValidate() {
region := VALID_SQS_CLIENT_REGION
c := &SQSClientConfig{
Region: ®ion,
}
err := validateConfigWithReflection(c)
assert.Nil(s.T(), err)
}
func (s *SQSClientConfigSuite) TestValidateWithEndpoint() {
region := VALID_SQS_CLIENT_REGION
endpoint := VALID_SQS_CLIENT_ENDPOINT
c := &SQSClientConfig{
Region: ®ion,
Endpoint: &endpoint,
}
err := validateConfigWithReflection(c)
assert.Nil(s.T(), err)
}
func (s *SQSClientConfigSuite) TestValidateErrorRegion() {
region := AWSRegion("invalidregion")
c := &SQSClientConfig{
Region: ®ion,
}
err := validateConfigWithReflection(c)
assert.NotNil(s.T(), err)
assert.Equal(s.T(), errors.New("Validater Field: Region, failed to validate with error, Region is invalid"), err)
}
func (s *SQSClientConfigSuite) TestValidateErrorEndpoint() {
region := VALID_SQS_CLIENT_REGION
endpoint := ""
c := &SQSClientConfig{
Region: ®ion,
Endpoint: &endpoint,
}
err := validateConfigWithReflection(c)
assert.NotNil(s.T(), err)
assert.Equal(s.T(), errors.New("String Field: Endpoint, contains an empty string"), err)
}
func (s *SQSClientConfigSuite) TestGetRegion() {
region := VALID_SQS_CLIENT_REGION
c := &SQSClientConfig{
Region: ®ion,
}
sRegion := c.GetRegion()
assert.Equal(s.T(), VALID_SQS_CLIENT_REGION, sRegion)
}
func (s *SQSClientConfigSuite) TestGetEndpoint() {
region := VALID_SQS_CLIENT_REGION
endpoint := VALID_SQS_CLIENT_ENDPOINT
c := &SQSClientConfig{
Region: ®ion,
Endpoint: &endpoint,
}
sEndpoint := c.GetEndpoint()
assert.Equal(s.T(), VALID_SQS_CLIENT_ENDPOINT, sEndpoint)
}