-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
55 lines (50 loc) · 1.42 KB
/
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
package main
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfig(t *testing.T) {
insufficientRemoteKubeConfigPath := []byte(`
{
"remotes": [
{
"remoteCAURL": "remote_ca_url",
"remoteAPIURL": "remote_api_url"
}
]
}
`)
_, err := parseConfig(insufficientRemoteKubeConfigPath)
assert.Equal(t, fmt.Errorf("Insufficient configuration to create remote cluster client. Set kubeConfigPath or apiURL and caURL and saTokenPath"), err)
rawFullConfig := []byte(`
{
"local": {
"kubeConfigPath": "/path/to/kube/config"
},
"remotes": [
{
"CAURL": "remote_ca_url",
"APIURL": "remote_api_url",
"SATokenPath": "/path/to/token"
},
{
"name": "remote_cluster_2",
"kubeConfigPath": "/path/to/kube/config"
}
]
}
`)
config, err := parseConfig(rawFullConfig)
assert.Equal(t, nil, err)
assert.Equal(t, "/path/to/kube/config", config.Local.KubeConfigPath)
assert.Equal(t, 2, len(config.Remotes))
assert.Equal(t, "remote_ca_url", config.Remotes[0].CAURL)
assert.Equal(t, "remote_api_url", config.Remotes[0].APIURL)
assert.Equal(t, "/path/to/token", config.Remotes[0].SATokenPath)
assert.Equal(t, "", config.Remotes[0].KubeConfigPath)
assert.Equal(t, "", config.Remotes[1].CAURL)
assert.Equal(t, "", config.Remotes[1].APIURL)
assert.Equal(t, "", config.Remotes[1].SATokenPath)
assert.Equal(t, "/path/to/kube/config", config.Remotes[1].KubeConfigPath)
}