@@ -38,6 +38,7 @@ import (
3838
3939 corev1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1"
4040 tenancyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1"
41+ kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster"
4142 kcpfakeclient "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster/fake"
4243)
4344
@@ -64,6 +65,7 @@ func TestCreate(t *testing.T) {
6465 AuthInfos : map [string ]* clientcmdapi.AuthInfo {"test" : {Token : "test" }},
6566 },
6667 newWorkspaceName : "bar" ,
68+ markReady : true ,
6769 },
6870 {
6971 name : "create, use after creation, but not ready" ,
@@ -193,6 +195,9 @@ func TestCreate(t *testing.T) {
193195 for _ , name := range tt .existingWorkspaces {
194196 objects = append (objects , & tenancyv1alpha1.Workspace {
195197 ObjectMeta : metav1.ObjectMeta {
198+ Annotations : map [string ]string {
199+ logicalcluster .AnnotationKey : currentClusterName .String (),
200+ },
196201 Name : name ,
197202 },
198203 Spec : tenancyv1alpha1.WorkspaceSpec {
@@ -209,6 +214,24 @@ func TestCreate(t *testing.T) {
209214 }
210215 client := kcpfakeclient .NewSimpleClientset (objects ... )
211216
217+ // Fill up the resources map for the discovery client
218+ for _ , name := range append (tt .existingWorkspaces , tt .newWorkspaceName ) {
219+ if client .Resources == nil {
220+ client .Resources = map [logicalcluster.Path ][]* metav1.APIResourceList {}
221+ }
222+ client .Resources [logicalcluster .NewPath (currentClusterName .String ()).Join (name )] = []* metav1.APIResourceList {
223+ {
224+ GroupVersion : tenancyv1alpha1 .SchemeGroupVersion .String (),
225+ APIResources : []metav1.APIResource {
226+ {
227+ Name : "workspaces" ,
228+ SingularName : "workspace" ,
229+ },
230+ },
231+ },
232+ }
233+ }
234+
212235 workspaceType := tt .newWorkspaceType
213236 if tt .newWorkspaceType == nil {
214237 workspaceType = & tenancyv1alpha1.WorkspaceTypeReference {
@@ -243,6 +266,9 @@ func TestCreate(t *testing.T) {
243266 return nil
244267 }
245268 opts .kcpClusterClient = client
269+ opts .newKCPClusterClient = func (config clientcmd.ClientConfig ) (kcpclientset.ClusterInterface , error ) {
270+ return client , nil
271+ }
246272 opts .ClientConfig = clientcmd .NewDefaultClientConfig (* tt .config .DeepCopy (), nil )
247273 err := opts .Run (context .Background ())
248274 if tt .wantErr {
0 commit comments