forked from weaveworks/weave-gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
suite_test.go
54 lines (40 loc) · 1.03 KB
/
suite_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
package clustersmngr_test
import (
"os"
"testing"
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
"github.com/weaveworks/weave-gitops/pkg/testutils"
"k8s.io/client-go/rest"
)
var k8sEnv *testutils.K8sTestEnv
func TestMain(m *testing.M) {
var err error
k8sEnv, err = testutils.StartK8sTestEnvironment([]string{
"../../manifests/crds",
"../../tools/testcrds",
})
if err != nil {
panic(err)
}
code := m.Run()
k8sEnv.Stop()
os.Exit(code)
}
func makeLeafCluster(t *testing.T, name string) cluster.Cluster {
cluster, err := cluster.NewSingleCluster(name, k8sEnv.Rest, nil)
if err != nil {
t.Error("Expected err to be nil, got", err)
}
return cluster
}
func makeUnreachableLeafCluster(t *testing.T, name string) cluster.Cluster {
c := rest.CopyConfig(k8sEnv.Rest)
// hopefully no k8s server is listening here
// FIXME: better addresses?
c.Host = "0.0.0.0:65535"
cluster, err := cluster.NewSingleCluster(name, c, nil)
if err != nil {
t.Error("Expected err to be nil, got", err)
}
return cluster
}