github.com/sleungcy-sap/cli@v7.1.0+incompatible/cf/requirements/targeted_space_test.go (about) 1 package requirements_test 2 3 import ( 4 "code.cloudfoundry.org/cli/cf/configuration/coreconfig" 5 "code.cloudfoundry.org/cli/cf/models" 6 . "code.cloudfoundry.org/cli/cf/requirements" 7 testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 ) 11 12 var _ = Describe("TargetedSpaceRequirement", func() { 13 var ( 14 config coreconfig.ReadWriter 15 ) 16 17 BeforeEach(func() { 18 config = testconfig.NewRepositoryWithDefaults() 19 }) 20 21 Context("when the user has targeted a space", func() { 22 It("succeeds", func() { 23 req := NewTargetedSpaceRequirement(config) 24 err := req.Execute() 25 Expect(err).NotTo(HaveOccurred()) 26 }) 27 }) 28 29 Context("when the user does not have a space targeted", func() { 30 It("errors", func() { 31 config.SetSpaceFields(models.SpaceFields{}) 32 33 err := NewTargetedSpaceRequirement(config).Execute() 34 35 Expect(err).To(HaveOccurred()) 36 Expect(err.Error()).To(ContainSubstring("No space targeted")) 37 }) 38 }) 39 })