Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Fix create class unit test on pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
artmello committed Jul 16, 2018
1 parent 0cef4a5 commit f709986
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/svcat/service-catalog/class_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ var _ = Describe("Class", func() {
svcCatClient *fake.Clientset
sc *v1beta1.ClusterServiceClass
sc2 *v1beta1.ClusterServiceClass
sc3 *v1beta1.ClusterServiceClass
)

BeforeEach(func() {
sc = &v1beta1.ClusterServiceClass{ObjectMeta: metav1.ObjectMeta{Name: "foobar"}}
sc2 = &v1beta1.ClusterServiceClass{ObjectMeta: metav1.ObjectMeta{Name: "barbaz"}}
sc3 = &v1beta1.ClusterServiceClass{ObjectMeta: metav1.ObjectMeta{Name: "fromclass"}}
svcCatClient = fake.NewSimpleClientset(sc, sc2)
sdk = &SDK{
ServiceCatalogClient: svcCatClient,
Expand Down Expand Up @@ -210,16 +212,15 @@ var _ = Describe("Class", func() {
Describe("CreateClass", func() {
It("Calls the generated v1beta1 create method with the passed in class", func() {
className := "newclass"
nc := &v1beta1.ClusterServiceClass{ObjectMeta: metav1.ObjectMeta{Name: className}}

class, err := sdk.CreateClass(nc)
sc3.Spec.ExternalName = className
class, err := sdk.CreateClass(sc3)

Expect(err).NotTo(HaveOccurred())
Expect(class).To(Equal(nc))
Expect(class).To(Equal(sc3))
actions := svcCatClient.Actions()
Expect(actions[0].Matches("create", "clusterserviceclasses")).To(BeTrue())
objectFromRequest := actions[0].(testing.CreateActionImpl).Object.(*v1beta1.ClusterServiceClass)
Expect(objectFromRequest.ObjectMeta.Name).To(Equal(className))
Expect(objectFromRequest.Spec.ExternalName).To(Equal(className))
})
It("Bubbles up errors", func() {
class, err := sdk.CreateClass(sc)
Expand Down

0 comments on commit f709986

Please sign in to comment.