github.com/cloudfoundry-incubator/stembuild@v0.0.0-20211223202937-5b61d62226c6/commandparser/construct_helpers_test.go (about) 1 package commandparser_test 2 3 import ( 4 . "github.com/cloudfoundry-incubator/stembuild/commandparser" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 "path/filepath" 8 ) 9 10 var _ = Describe("construct_helpers", func() { 11 12 Describe("IsArtifactInDirectory", func() { 13 Context("Directory given is valid", func() { 14 15 Describe("LGPO", func() { 16 filename := "LGPO.zip" 17 18 Context("LGPO is not present", func() { 19 dir := filepath.Join("..", "test", "constructData", "emptyDir") 20 21 It("should return false with no error", func() { 22 present, err := IsArtifactInDirectory(dir, filename) 23 Expect(err).ToNot(HaveOccurred()) 24 Expect(present).To(BeFalse()) 25 }) 26 }) 27 28 Context("artifact is present", func() { 29 dir := filepath.Join("..", "test", "constructData", "fullDir") 30 31 It("should return true with no error", func() { 32 present, err := IsArtifactInDirectory(dir, filename) 33 Expect(err).ToNot(HaveOccurred()) 34 Expect(present).To(BeTrue()) 35 }) 36 }) 37 }) 38 }) 39 40 Context("Directory given is not valid", func() { 41 filename := "file" 42 It("should return an error", func() { 43 dir := filepath.Join("..", "test", "constructData", "notExist") 44 _, err := IsArtifactInDirectory(dir, filename) 45 Expect(err).To(HaveOccurred()) 46 }) 47 }) 48 }) 49 })