Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Add test that checks List works on UnstructuredList not in Scheme #1288

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,36 @@ var _ = Describe("Client", func() {
close(done)
}, serverSideTimeoutSeconds)

It("should fetch unstructured collection of objects, even if scheme is empty", func(done Done) {
By("create an initial object")
_, err := clientset.AppsV1().Deployments(ns).Create(ctx, dep, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

cl, err := client.New(cfg, client.Options{Scheme: runtime.NewScheme()})
Expect(err).NotTo(HaveOccurred())

By("listing all objects of that type in the cluster")
deps := &unstructured.UnstructuredList{}
deps.SetGroupVersionKind(schema.GroupVersionKind{
Group: "apps",
Kind: "DeploymentList",
Version: "v1",
})
err = cl.List(context.Background(), deps)
Expect(err).NotTo(HaveOccurred())

Expect(deps.Items).NotTo(BeEmpty())
hasDep := false
for _, item := range deps.Items {
if item.GetName() == dep.Name && item.GetNamespace() == dep.Namespace {
hasDep = true
break
}
}
Expect(hasDep).To(BeTrue())
close(done)
}, serverSideTimeoutSeconds)

It("should return an empty list if there are no matching objects", func(done Done) {
cl, err := client.New(cfg, client.Options{})
Expect(err).NotTo(HaveOccurred())
Expand Down