-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclient_test.go
More file actions
65 lines (61 loc) · 1.91 KB
/
client_test.go
File metadata and controls
65 lines (61 loc) · 1.91 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 (
"fmt"
"testing"
"github.com/arschles/assert"
"github.com/deis/builder/pkg/sys"
)
type getClientTestCase struct {
fileSystem map[string][]byte
envs map[string]string
expectClient bool
expectErr bool
}
func TestGetClientEmptyAuth(t *testing.T) {
testCases := []getClientTestCase{
// no auth & outside storage
getClientTestCase{
fileSystem: make(map[string][]byte),
envs: map[string]string{"DEIS_OUTSIDE_STORAGE": "http://outside.com"},
expectClient: true,
expectErr: false,
},
// invalid auth - missing secret
getClientTestCase{
fileSystem: map[string][]byte{accessKeyIDFile: []byte("access key")},
envs: map[string]string{"DEIS_OUTSIDE_STORAGE": "http://outside.com"},
expectClient: false,
expectErr: true,
},
// invalid auth - missing key
getClientTestCase{
fileSystem: map[string][]byte{accessSecretKeyFile: []byte("access secret")},
envs: map[string]string{"DEIS_OUTSIDE_STORAGE": "http://outside.com"},
expectClient: false,
expectErr: true,
},
// invalid endpoint
getClientTestCase{
fileSystem: make(map[string][]byte),
envs: make(map[string]string),
expectClient: false,
expectErr: true,
},
// valid auth, outside storage
getClientTestCase{
fileSystem: map[string][]byte{accessKeyIDFile: []byte("access key"), accessSecretKeyFile: []byte("access secret")},
envs: map[string]string{"DEIS_OUTSIDE_STORAGE": "http://outside.com"},
expectClient: true,
expectErr: false,
},
}
for i, testCase := range testCases {
fs := sys.NewFakeFS()
fs.Files = testCase.fileSystem
env := sys.NewFakeEnv()
env.Envs = testCase.envs
cl, err := GetClient("myrevion", fs, env)
assert.Equal(t, testCase.expectClient, cl != nil, fmt.Sprintf("returned client %d", i))
assert.Equal(t, testCase.expectErr, err != nil, fmt.Sprintf("returned error %d", i))
}
}