github.com/sleungcy-sap/cli@v7.1.0+incompatible/cf/models/service_plan_test.go (about) 1 package models_test 2 3 import ( 4 . "code.cloudfoundry.org/cli/cf/models" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("ServicePlanFields", func() { 10 var servicePlanFields ServicePlanFields 11 12 BeforeEach(func() { 13 servicePlanFields = ServicePlanFields{ 14 GUID: "I-am-a-guid", 15 Name: "BestServicePlanEver", 16 Free: false, 17 Public: true, 18 Description: "A Plan For Service", 19 Active: true, 20 ServiceOfferingGUID: "service-offering-guid", 21 OrgNames: []string{"org1", "org2"}, 22 } 23 }) 24 25 Describe(".OrgHasVisibility", func() { 26 Context("when the service plan is public", func() { 27 It("returns true", func() { 28 Expect(servicePlanFields.OrgHasVisibility("anyOrg")).To(BeTrue()) 29 }) 30 }) 31 32 Context("when the service plan is not public", func() { 33 BeforeEach(func() { 34 servicePlanFields.Public = false 35 }) 36 37 It("returns true if the orgname is in the list of orgs that have visibility", func() { 38 Expect(servicePlanFields.OrgHasVisibility("org1")).To(BeTrue()) 39 }) 40 41 It("returns false if the orgname is not in the list of orgs that have visibility", func() { 42 Expect(servicePlanFields.OrgHasVisibility("org-that-has-no-visibility")).To(BeFalse()) 43 }) 44 }) 45 46 }) 47 })