forked from kyma-project/cp-mod-migrator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cp_mod_migration_suite_test.go
69 lines (54 loc) · 1.51 KB
/
cp_mod_migration_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main_test
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v211 "github.tools.sap/framefrog/cp-mod-migrator/pkg/cproxy/api/v211"
"github.tools.sap/framefrog/cp-mod-migrator/pkg/extract"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/rest"
"k8s.io/kubectl/pkg/scheme"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
)
func TestCproxy(t *testing.T) {
RegisterFailHandler(Fail)
if err := loadCMs(&cms); err != nil {
t.Fatal(err)
}
mockedClient = newClient(t, cms)
RunSpecs(t, "Cproxy Suite")
}
var (
externalDependencyDataPath = "./hack/cproxy/crd.yaml"
testEnv *envtest.Environment
k8sClient client.Client
config *rest.Config
mockedClient extract.Client
cms []corev1.ConfigMap
)
func getK8sClient() (client.Client, error) {
return k8sClient, nil
}
var _ = BeforeSuite(func() {
By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{
externalDependencyDataPath,
}, ErrorIfCRDPathMissing: true,
}
var err error
config, err = testEnv.Start()
Expect(err).NotTo(HaveOccurred())
Expect(config).NotTo(BeNil())
err = v211.AddToScheme(scheme.Scheme)
Expect(err).ShouldNot(HaveOccurred())
k8sClient, err = client.New(config, client.Options{Scheme: scheme.Scheme})
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient).NotTo(BeNil())
})
var _ = AfterSuite(func() {
By("tearing down the test environment")
err := testEnv.Stop()
Expect(err).NotTo(HaveOccurred())
})