-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_test.go
43 lines (40 loc) · 905 Bytes
/
get_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
package workutils
import (
"testing"
testify "github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/scheme"
workapiv1 "open-cluster-management.io/api/work/v1"
)
func TestGet(t *testing.T) {
nsStr := `
apiVersion: v1
kind: Namespace
metadata:
name: test-namespace
`
raw, err := stringToRawExtension(nsStr)
testify.Nil(t, err)
work := workapiv1.ManifestWork{
Spec: workapiv1.ManifestWorkSpec{
Workload: workapiv1.ManifestsTemplate{
Manifests: []workapiv1.Manifest{
{
RawExtension: raw,
},
},
},
},
}
client := NewWorkUtilsClient(scheme.Scheme)
obj, err := client.Get(work, Resource{
Group: "",
Version: "v1",
Kind: "Namespace",
Name: "test-namespace",
})
testify.Nil(t, err)
namespace, ok := obj.(*corev1.Namespace)
testify.Equal(t, true, ok)
testify.Equal(t, "test-namespace", namespace.Name)
}