Skip to content

Commit 8ade6d7

Browse files
committed
Update fake client tests to use typed Lists
This is enabled by new type support in fake client List. Other tests may also be updated to use this style.
1 parent 8f3407b commit 8ade6d7

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

pkg/client/fake/client_test.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ limitations under the License.
1717
package fake
1818

1919
import (
20-
"encoding/json"
21-
2220
. "github.com/onsi/ginkgo"
2321
. "github.com/onsi/gomega"
2422

@@ -68,22 +66,13 @@ var _ = Describe("Fake client", func() {
6866

6967
It("should be able to List", func() {
7068
By("Listing all deployments in a namespace")
71-
list := &metav1.List{}
69+
list := &appsv1.DeploymentList{}
7270
err := cl.List(nil, &client.ListOptions{
7371
Namespace: "ns1",
74-
Raw: &metav1.ListOptions{
75-
TypeMeta: metav1.TypeMeta{
76-
APIVersion: "apps/v1",
77-
Kind: "Deployment",
78-
},
79-
},
8072
}, list)
8173
Expect(err).To(BeNil())
8274
Expect(list.Items).To(HaveLen(1))
83-
j, err := json.Marshal(dep)
84-
Expect(err).To(BeNil())
85-
expectedDep := runtime.RawExtension{Raw: j}
86-
Expect(list.Items).To(ConsistOf(expectedDep))
75+
Expect(list.Items).To(ConsistOf(*dep))
8776
})
8877

8978
It("should be able to Create", func() {
@@ -139,15 +128,9 @@ var _ = Describe("Fake client", func() {
139128
Expect(err).To(BeNil())
140129

141130
By("Listing all deployments in the namespace")
142-
list := &metav1.List{}
131+
list := &appsv1.DeploymentList{}
143132
err = cl.List(nil, &client.ListOptions{
144133
Namespace: "ns1",
145-
Raw: &metav1.ListOptions{
146-
TypeMeta: metav1.TypeMeta{
147-
APIVersion: "apps/v1",
148-
Kind: "Deployment",
149-
},
150-
},
151134
}, list)
152135
Expect(err).To(BeNil())
153136
Expect(list.Items).To(HaveLen(0))

0 commit comments

Comments
 (0)