...
1
16
17 package create
18
19 import (
20 corev1 "k8s.io/api/core/v1"
21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22 "testing"
23
24 apiequality "k8s.io/apimachinery/pkg/api/equality"
25 )
26
27 func TestCreateNamespace(t *testing.T) {
28 tests := map[string]struct {
29 options *NamespaceOptions
30 expected *corev1.Namespace
31 }{
32 "success_create": {
33 options: &NamespaceOptions{
34 Name: "my-namespace",
35 },
36 expected: &corev1.Namespace{
37 TypeMeta: metav1.TypeMeta{
38 Kind: "Namespace",
39 APIVersion: "v1",
40 },
41 ObjectMeta: metav1.ObjectMeta{
42 Name: "my-namespace",
43 },
44 },
45 },
46 }
47 for name, tc := range tests {
48 t.Run(name, func(t *testing.T) {
49 namespace := tc.options.createNamespace()
50 if !apiequality.Semantic.DeepEqual(namespace, tc.expected) {
51 t.Errorf("expected:\n%#v\ngot:\n%#v", tc.expected, namespace)
52 }
53 })
54 }
55 }
56
View as plain text