-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathendpoint_test.go
More file actions
65 lines (61 loc) · 1.57 KB
/
endpoint_test.go
File metadata and controls
65 lines (61 loc) · 1.57 KB
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
package storage
import (
"testing"
"github.com/arschles/assert"
"github.com/deis/builder/pkg/sys"
)
type getEndpointTestCase struct {
envVars map[string]string
expectedOut string
expectedErr error
}
func TestGetEndpoint(t *testing.T) {
testCases := []getEndpointTestCase{
getEndpointTestCase{
envVars: map[string]string{"DEIS_OUTSIDE_STORAGE": "http://outside.storage.com"},
expectedOut: "http://outside.storage.com",
},
getEndpointTestCase{
envVars: map[string]string{"DEIS_OUTSIDE_STORAGE": "https://outside.com"},
expectedOut: "https://outside.com",
},
getEndpointTestCase{
envVars: map[string]string{
"DEIS_OUTSIDE_STORAGE": "outside.com",
"DEIS_MINIO_SERVICE_HOST": "minio.com",
"DEIS_MINIO_SERVICE_PORT": "8888",
},
expectedOut: "outside.com",
},
getEndpointTestCase{
envVars: map[string]string{
"DEIS_MINIO_SERVICE_HOST": "minio.com",
"DEIS_MINIO_SERVICE_PORT": "8888",
},
expectedOut: "http://minio.com:8888",
},
getEndpointTestCase{
envVars: map[string]string{
"DEIS_MINIO_SERVICE_HOST": "minio.com",
},
expectedErr: errNoStorageConfig,
},
getEndpointTestCase{
envVars: map[string]string{
"DEIS_MINIO_SERVICE_PORT": "9999",
},
expectedErr: errNoStorageConfig,
},
}
for _, testCase := range testCases {
fe := sys.NewFakeEnv()
fe.Envs = testCase.envVars
str, err := getEndpoint(fe)
assert.Equal(t, str, testCase.expectedOut, "output")
if testCase.expectedErr == nil {
assert.NoErr(t, err)
} else {
assert.Equal(t, err, testCase.expectedErr, "error")
}
}
}