-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
2,231 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
# This generates the fakes based on the vendored version of service-catalog. | ||
# Note that some hand-editing is required to fix the namespace collision of | ||
# generated and regular v1beta1 packages. Rewrite the import paths to be | ||
# generic rather than the vendor directory. Import the clientset_generated | ||
# version of the package as a different name, and rewrite the final line | ||
# to use the new name. | ||
|
||
counterfeiter -o pkg/plugin_client/fakes/fake_interface.go vendor/github.com/kubernetes-incubator/service-catalog/pkg/client/clientset_generated/clientset/ Interface | ||
counterfeiter -o pkg/plugin_client/fakes/fake_servicecatalogv1beta1_interface.go vendor/github.com/kubernetes-incubator/service-catalog/pkg/client/clientset_generated/clientset/typed/servicecatalog/v1beta1/servicecatalog_client.go ServicecatalogV1beta1Interface | ||
counterfeiter -o pkg/plugin_client/fakes/fake_servicebinding_interface.go vendor/github.com/kubernetes-incubator/service-catalog/pkg/client/clientset_generated/clientset/typed/servicecatalog/v1beta1/servicebinding.go ServiceBindingInterface | ||
counterfeiter -o pkg/plugin_client/fakes/fake_clusterservicebroker_interface.go vendor/github.com/kubernetes-incubator/service-catalog/pkg/client/clientset_generated/clientset/typed/servicecatalog/v1beta1/clusterservicebroker.go ClusterServiceBrokerInterface | ||
counterfeiter -o pkg/plugin_client/fakes/fake_clusterservicebroker_interface.go vendor/github.com/kubernetes-incubator/service-catalog/pkg/client/clientset_generated/clientset/typed/servicecatalog/v2beta1/clusterservicebroker.go ClusterServiceBrokerInterface | ||
counterfeiter -o pkg/plugin_client/fakes/fake_clusterserviceclass_interface.go vendor/github.com/kubernetes-incubator/service-catalog/pkg/client/clientset_generated/clientset/typed/servicecatalog/v1beta1/clusterserviceclass.go ClusterServiceClassInterface | ||
counterfeiter -o pkg/plugin_client/fakes/fake_clusterserviceplan_interface.go vendor/github.com/kubernetes-incubator/service-catalog/pkg/client/clientset_generated/clientset/typed/servicecatalog/v1beta1/clusterserviceplan.go ClusterServicePlanInterface | ||
counterfeiter -o pkg/plugin_client/fakes/fake_serviceinstance_interface.go vendor/github.com/kubernetes-incubator/service-catalog/pkg/client/clientset_generated/clientset/typed/servicecatalog/v1beta1/serviceinstance.go ServiceInstanceInterface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package plugin_client_test | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/jberkhahn/service-catalog-plugins/pkg/plugin_client" | ||
"github.com/jberkhahn/service-catalog-plugins/pkg/plugin_client/fakes" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Class", func() { | ||
var ( | ||
client *plugin_client.PluginClient | ||
err error | ||
FakeScClient *fakes.FakeInterface | ||
ServicecatalogV1beta1 *fakes.FakeServicecatalogV1beta1Interface | ||
ClusterServiceClasses *fakes.FakeClusterServiceClassInterface | ||
) | ||
|
||
BeforeEach(func() { | ||
client, err = plugin_client.NewClient() | ||
Expect(err).NotTo(HaveOccurred()) | ||
FakeScClient = &fakes.FakeInterface{} | ||
ServicecatalogV1beta1 = &fakes.FakeServicecatalogV1beta1Interface{} | ||
ClusterServiceClasses = &fakes.FakeClusterServiceClassInterface{} | ||
|
||
client.ScClient = FakeScClient | ||
FakeScClient.ServicecatalogV1beta1Returns(ServicecatalogV1beta1) | ||
ServicecatalogV1beta1.ClusterServiceClassesReturns(ClusterServiceClasses) | ||
}) | ||
|
||
Describe("Get", func() { | ||
It("Calls the generated v1beta1 List method with the passed in class", func() { | ||
className := "foobar" | ||
_, err = client.GetClass(className) | ||
|
||
Expect(ClusterServiceClasses.GetCallCount()).To(Equal(1)) | ||
name, _ := ClusterServiceClasses.GetArgsForCall(0) | ||
Expect(name).To(Equal(className)) | ||
}) | ||
It("Bubbles up errors", func() { | ||
errorMessage := "class not found" | ||
ClusterServiceClasses.GetReturns(nil, errors.New(errorMessage)) | ||
|
||
_, err := client.GetClass("banana") | ||
|
||
Expect(err).To(HaveOccurred()) | ||
Expect(err.Error()).Should(ContainSubstring(errorMessage)) | ||
Expect(ClusterServiceClasses.GetCallCount()).To(Equal(1)) | ||
}) | ||
}) | ||
|
||
Describe("List", func() { | ||
It("Calls the generated v1beta1 List method", func() { | ||
_, err := client.ListClasses() | ||
|
||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(ClusterServiceClasses.ListCallCount()).To(Equal(1)) | ||
}) | ||
It("Bubbles up errors", func() { | ||
errorMessage := "foobar" | ||
ClusterServiceClasses.ListReturns(nil, errors.New(errorMessage)) | ||
|
||
_, err := client.ListClasses() | ||
|
||
Expect(err).To(HaveOccurred()) | ||
Expect(err.Error()).Should(ContainSubstring(errorMessage)) | ||
Expect(ClusterServiceClasses.ListCallCount()).To(Equal(1)) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.