test: integration test the helloworld subresource (#96443)

pull/96438/head
Mariell Hoversholm 8 months ago committed by GitHub
parent b88f42ca82
commit 5213a801f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      pkg/registry/apis/provisioning/hello.go
  2. 27
      pkg/tests/apis/provisioning/provisioning_test.go

@ -49,7 +49,7 @@ func (*helloWorldSubresource) Connect(ctx context.Context, name string, opts run
whom = "World"
}
responder.Object(http.StatusTeapot, &v0alpha1.HelloWorld{Whom: whom})
responder.Object(http.StatusOK, &v0alpha1.HelloWorld{Whom: whom})
}), nil
}

@ -61,6 +61,15 @@ func TestIntegrationProvisioning(t *testing.T) {
"update",
"watch"
]
},
{
"name": "repositories/hello",
"singularName": "",
"kind": "HelloWorld",
"namespaced": true,
"verbs": [
"get"
]
}
]
}`, string(v1Disco))
@ -94,6 +103,24 @@ func TestIntegrationProvisioning(t *testing.T) {
mustNestedString(r1.Object, "spec", "local", "path"),
)
})
t.Run("basic helloworld subresource", func(t *testing.T) {
client := helper.GetResourceClient(apis.ResourceClientArgs{
User: helper.Org1.Admin,
Namespace: "default", // actually org1
GVR: schema.GroupVersionResource{
Group: "provisioning.grafana.app",
Version: "v0alpha1",
Resource: "repositories",
},
})
resp, err := client.Resource.Get(ctx, "test", metav1.GetOptions{}, "hello")
require.NoError(t, err)
require.Equal(t,
"World",
mustNestedString(resp.Object, "whom"))
})
}
func mustNestedString(obj map[string]interface{}, fields ...string) string {

Loading…
Cancel
Save