-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdynamodb_client_config_test.go
139 lines (105 loc) · 3.14 KB
/
dynamodb_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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package remoteconfig
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
const (
VALID_DYNAMODB_CLIENT_REGION AWSRegion = AWS_REGION_US_EAST_1
VALID_DYNAMODB_CLIENT_ENDPOINT string = "http://localhost:8000/dynamodb"
VALID_DYNAMODB_CLIENT_DISABLE_SSL bool = true
)
type DynamoDBClientConfigSuite struct {
suite.Suite
}
func TestDynamoDBClientConfigSuite(t *testing.T) {
suite.Run(t, new(DynamoDBClientConfigSuite))
}
func (s *DynamoDBClientConfigSuite) SetupSuite() {
}
func (s *DynamoDBClientConfigSuite) SetupTest() {
}
func (s *DynamoDBClientConfigSuite) TestValidate() {
region := VALID_DYNAMODB_CLIENT_REGION
endpoint := VALID_DYNAMODB_CLIENT_ENDPOINT
d := &DynamoDBClientConfig{
Region: ®ion,
Endpoint: &endpoint,
}
err := validateConfigWithReflection(d)
assert.Nil(s.T(), err)
}
func (s *DynamoDBClientConfigSuite) TestValidateWithoutEndpoint() {
region := VALID_DYNAMODB_CLIENT_REGION
d := &DynamoDBClientConfig{
Region: ®ion,
}
err := validateConfigWithReflection(d)
assert.Nil(s.T(), err)
}
func (s *DynamoDBClientConfigSuite) TestValidateErrorEmptyEndpoint() {
region := VALID_DYNAMODB_CLIENT_REGION
endpoint := ""
d := &DynamoDBClientConfig{
Region: ®ion,
Endpoint: &endpoint,
}
err := validateConfigWithReflection(d)
assert.NotNil(s.T(), err)
assert.Equal(s.T(), errors.New("String Field: Endpoint, contains an empty string"), err)
}
func (s *DynamoDBClientConfigSuite) TestValidateErrorRegion() {
region := AWSRegion("")
d := &DynamoDBClientConfig{
Region: ®ion,
}
err := validateConfigWithReflection(d)
assert.NotNil(s.T(), err)
assert.Equal(s.T(), errors.New("Validater Field: Region, failed to validate with error, Region cannot be empty"), err)
}
func (s *DynamoDBClientConfigSuite) TestGetRegion() {
region := VALID_DYNAMODB_CLIENT_REGION
d := &DynamoDBClientConfig{
Region: ®ion,
}
assert.Equal(s.T(), VALID_DYNAMODB_CLIENT_REGION, d.GetRegion())
}
func (s *DynamoDBClientConfigSuite) TestGetEndpoint() {
region := VALID_DYNAMODB_CLIENT_REGION
endpoint := VALID_DYNAMODB_CLIENT_ENDPOINT
d := &DynamoDBClientConfig{
Region: ®ion,
Endpoint: &endpoint,
}
assert.Equal(s.T(), VALID_DYNAMODB_CLIENT_ENDPOINT, d.GetEndpoint())
}
func (s *DynamoDBClientConfigSuite) TestGetEndpointNotSet() {
region := VALID_DYNAMODB_CLIENT_REGION
d := &DynamoDBClientConfig{
Region: ®ion,
Endpoint: nil,
}
assert.Equal(s.T(), "", d.GetEndpoint())
}
func (s *DynamoDBClientConfigSuite) TestGetDisableSSL() {
region := VALID_DYNAMODB_CLIENT_REGION
endpoint := VALID_DYNAMODB_CLIENT_ENDPOINT
disableSSL := VALID_DYNAMODB_CLIENT_DISABLE_SSL
d := &DynamoDBClientConfig{
Region: ®ion,
Endpoint: &endpoint,
DisableSSL: &disableSSL,
}
assert.Equal(s.T(), VALID_DYNAMODB_CLIENT_DISABLE_SSL, d.GetDisableSSL())
}
func (s *DynamoDBClientConfigSuite) TestGetDisableSSLNotSet() {
region := VALID_DYNAMODB_CLIENT_REGION
endpoint := VALID_DYNAMODB_CLIENT_ENDPOINT
d := &DynamoDBClientConfig{
Region: ®ion,
Endpoint: &endpoint,
DisableSSL: nil,
}
assert.Equal(s.T(), false, d.GetDisableSSL())
}