-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaws_region_test.go
66 lines (54 loc) · 1.4 KB
/
aws_region_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
package remoteconfig
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type AWSRegionSuite struct {
suite.Suite
}
func TestAWSRegionSuite(t *testing.T) {
suite.Run(t, new(AWSRegionSuite))
}
func (s *AWSRegionSuite) SetupSuite() {
}
func (s *AWSRegionSuite) SetupTest() {
}
func (s *AWSRegionSuite) TestValidateUSEast1() {
r := AWS_REGION_US_EAST_1
err := r.Validate()
assert.Nil(s.T(), err)
}
func (s *AWSRegionSuite) TestValidateErrorNoRegion() {
r := AWSRegion("")
err := r.Validate()
assert.NotNil(s.T(), err)
assert.Equal(s.T(), ErrAWSRegionEmptyString, err)
}
func (s *AWSRegionSuite) TestValidateErrorInvalidRegion() {
r := AWSRegion("invalidregion")
err := r.Validate()
assert.NotNil(s.T(), err)
assert.Equal(s.T(), ErrAWSRegionInvalid, err)
}
func (s *AWSRegionSuite) TestUnmarshalText() {
r := AWSRegion("")
d := []byte(AWS_REGION_US_EAST_1)
err := r.UnmarshalText(d)
assert.Nil(s.T(), err)
assert.Equal(s.T(), AWS_REGION_US_EAST_1, r)
}
func (s *AWSRegionSuite) TestUnmarshalErrorNoRegion() {
r := AWSRegion("")
d := []byte("")
err := r.UnmarshalText(d)
assert.NotNil(s.T(), err)
assert.Equal(s.T(), ErrAWSRegionEmptyString, err)
}
func (s *AWSRegionSuite) TestUnmarshalErrorInvalidRegion() {
r := AWSRegion("")
d := []byte("invalidregion")
err := r.UnmarshalText(d)
assert.NotNil(s.T(), err)
assert.Equal(s.T(), ErrAWSRegionInvalid, err)
}