@@ -26,6 +26,8 @@ import (
26
26
crclientset "k8s.io/cluster-registry/pkg/client/clientset/versioned"
27
27
)
28
28
29
+ const testNamepace = "default"
30
+
29
31
func TestClusterCRUD (t * testing.T ) {
30
32
testenv := & test.TestEnvironment {CRDs : []* v1beta1.CustomResourceDefinition {& v1alpha1 .ClusterCRD }}
31
33
@@ -60,9 +62,10 @@ func TestClusterCRUD(t *testing.T) {
60
62
}
61
63
62
64
func testClusterCreate (t * testing.T , clientset * crclientset.Clientset , clusterName string ) {
63
- cluster , err := clientset .ClusterregistryV1alpha1 ().Clusters ().Create (& v1alpha1.Cluster {
65
+ cluster , err := clientset .ClusterregistryV1alpha1 ().Clusters (testNamepace ).Create (& v1alpha1.Cluster {
64
66
ObjectMeta : metav1.ObjectMeta {
65
- Name : clusterName ,
67
+ Name : clusterName ,
68
+ Namespace : testNamepace ,
66
69
},
67
70
})
68
71
@@ -76,7 +79,7 @@ func testClusterCreate(t *testing.T, clientset *crclientset.Clientset, clusterNa
76
79
}
77
80
78
81
func testClusterGet (t * testing.T , clientset * crclientset.Clientset , clusterName string ) {
79
- cluster , err := clientset .ClusterregistryV1alpha1 ().Clusters ().Get (clusterName ,
82
+ cluster , err := clientset .ClusterregistryV1alpha1 ().Clusters (testNamepace ).Get (clusterName ,
80
83
metav1.GetOptions {})
81
84
82
85
if err != nil {
@@ -89,7 +92,7 @@ func testClusterGet(t *testing.T, clientset *crclientset.Clientset, clusterName
89
92
}
90
93
91
94
func testClusterUpdate (t * testing.T , clientset * crclientset.Clientset , clusterName string ) {
92
- cluster , err := clientset .ClusterregistryV1alpha1 ().Clusters ().Get (clusterName , metav1.GetOptions {})
95
+ cluster , err := clientset .ClusterregistryV1alpha1 ().Clusters (testNamepace ).Get (clusterName , metav1.GetOptions {})
93
96
if err != nil {
94
97
t .Fatalf ("Unexpected error: %v" , err )
95
98
}
@@ -102,7 +105,7 @@ func testClusterUpdate(t *testing.T, clientset *crclientset.Clientset, clusterNa
102
105
},
103
106
}
104
107
105
- cluster , err = clientset .ClusterregistryV1alpha1 ().Clusters ().Update (cluster )
108
+ cluster , err = clientset .ClusterregistryV1alpha1 ().Clusters (testNamepace ).Update (cluster )
106
109
107
110
if err != nil {
108
111
t .Fatalf ("Unexpected error: %v" , err )
@@ -117,15 +120,15 @@ func testClusterUpdate(t *testing.T, clientset *crclientset.Clientset, clusterNa
117
120
}
118
121
119
122
func testClusterDelete (t * testing.T , clientset * crclientset.Clientset , clusterName string ) {
120
- err := clientset .ClusterregistryV1alpha1 ().Clusters ().Delete (clusterName ,
123
+ err := clientset .ClusterregistryV1alpha1 ().Clusters (testNamepace ).Delete (clusterName ,
121
124
& metav1.DeleteOptions {})
122
125
123
126
if err != nil {
124
127
t .Fatalf ("Unexpected error: %v" , err )
125
128
}
126
129
127
130
// We do not expect to find the cluster we just deleted
128
- _ , err = clientset .ClusterregistryV1alpha1 ().Clusters ().Get (clusterName , metav1.GetOptions {})
131
+ _ , err = clientset .ClusterregistryV1alpha1 ().Clusters (testNamepace ).Get (clusterName , metav1.GetOptions {})
129
132
130
133
if err == nil {
131
134
t .Fatalf ("Unexpected error: %v" , err )
0 commit comments