-
Notifications
You must be signed in to change notification settings - Fork 4
/
s3_endpoint_expiry_config_test.go
93 lines (70 loc) · 1.99 KB
/
s3_endpoint_expiry_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
package remoteconfig
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
const (
VALID_S3_ENDPOINT_EXPIRY_CONFIG_ENDPOINT string = "http://localhost:9500/s3"
VALID_S3_ENDPOINT_EXPIRY_CONFIG_EXPIRY uint = 30
)
type S3EndpointExpiryConfigSuite struct {
suite.Suite
}
func TestS3EndpointExpiryConfigSuite(t *testing.T) {
suite.Run(t, new(S3EndpointExpiryConfigSuite))
}
func (s *S3EndpointExpiryConfigSuite) SetupSuite() {
}
func (s *S3EndpointExpiryConfigSuite) SetupTest() {
}
func (s *S3EndpointExpiryConfigSuite) TestValidate() {
endpoint := VALID_S3_CONFIG_ENDPOINT
expiry := VALID_S3_CONFIG_EXPIRY
c := &S3EndpointExpiryConfig{
Endpoint: &endpoint,
Expiry: &expiry,
}
err := validateConfigWithReflection(c)
assert.Nil(s.T(), err)
}
func (s *S3EndpointExpiryConfigSuite) TestValidateErrorEndpoint() {
endpoint := ""
c := &S3EndpointExpiryConfig{
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 *S3EndpointExpiryConfigSuite) TestGetExpirySet() {
expiry := VALID_S3_CONFIG_EXPIRY
c := &S3EndpointExpiryConfig{
Expiry: &expiry,
}
cExpiry := c.GetExpiry()
assert.Equal(s.T(), VALID_S3_ENDPOINT_EXPIRY_CONFIG_EXPIRY, cExpiry)
}
func (s *S3EndpointExpiryConfigSuite) TestGetExpiryNotSet() {
c := &S3EndpointExpiryConfig{
Expiry: nil,
}
cExpiry := c.GetExpiry()
assert.Equal(s.T(), S3_ENDPOINT_EXPIRY_CONFIG_DEFAULT_EXPIRY, cExpiry)
}
func (s *S3EndpointExpiryConfigSuite) TestGetEndpointSet() {
endpoint := VALID_S3_CONFIG_ENDPOINT
c := &S3EndpointExpiryConfig{
Endpoint: &endpoint,
}
cEndpoint := c.GetEndpoint()
assert.Equal(s.T(), VALID_S3_ENDPOINT_EXPIRY_CONFIG_ENDPOINT, cEndpoint)
}
func (s *S3EndpointExpiryConfigSuite) TestGetEndpointNotSet() {
c := &S3EndpointExpiryConfig{
Endpoint: nil,
}
cEndpoint := c.GetEndpoint()
assert.Equal(s.T(), "", cEndpoint)
}