-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkubeconfig_test.go
More file actions
50 lines (47 loc) · 925 Bytes
/
kubeconfig_test.go
File metadata and controls
50 lines (47 loc) · 925 Bytes
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
package main
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestFilteredContexts(t *testing.T) {
var savedContexts = Contexts
var savedContextsFlags = contextsFlag
Contexts = ContextsConfig{
Contexts: []ContextsDetails{
{
Name: "gke_cluster_ci-0",
},
{
Name: "gke_cluster_pro-1",
},
{
Name: "minikube",
},
},
}
contextsFlag = []string{
"ci-\\d+",
"minikube",
}
defer func() {
Contexts = savedContexts
contextsFlag = savedContextsFlags
}()
var expectedContexts = []ContextsDetails{
{
Name: "gke_cluster_ci-0",
},
{
Name: "minikube",
},
}
t.Run("filtering contexts", func(t *testing.T) {
filteredContexts, err := getFilteredContexts()
if err != nil {
t.Fatalf("error while filtering contexts, err: %v", err)
}
if diff := cmp.Diff(expectedContexts, filteredContexts); diff != "" {
t.Errorf("diff (-want +got):\n%s", diff)
}
})
}