github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/requirements/buildpack_test.go (about) 1 package requirements_test 2 3 import ( 4 "code.cloudfoundry.org/cli/cf/api/apifakes" 5 "code.cloudfoundry.org/cli/cf/models" 6 . "code.cloudfoundry.org/cli/cf/requirements" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 ) 10 11 var _ = Describe("BuildpackRequirement", func() { 12 It("succeeds when a buildpack with the given name exists", func() { 13 buildpack := models.Buildpack{Name: "my-buildpack"} 14 buildpackRepo := &apifakes.OldFakeBuildpackRepository{FindByNameBuildpack: buildpack} 15 16 buildpackReq := NewBuildpackRequirement("my-buildpack", buildpackRepo) 17 18 Expect(buildpackReq.Execute()).NotTo(HaveOccurred()) 19 Expect(buildpackRepo.FindByNameName).To(Equal("my-buildpack")) 20 Expect(buildpackReq.GetBuildpack()).To(Equal(buildpack)) 21 }) 22 23 It("fails when the buildpack cannot be found", func() { 24 buildpackRepo := &apifakes.OldFakeBuildpackRepository{FindByNameNotFound: true} 25 26 err := NewBuildpackRequirement("foo", buildpackRepo).Execute() 27 Expect(err).To(HaveOccurred()) 28 Expect(err.Error()).To(ContainSubstring("Buildpack foo not found")) 29 }) 30 })