github.com/chenbh/concourse/v6@v6.4.2/atc/atc_test.go (about) 1 package atc_test 2 3 import ( 4 "github.com/chenbh/concourse/v6/atc" 5 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 ) 9 10 var _ = Describe("Config", func() { 11 var config atc.Config 12 13 Describe("determining if a job's builds are publically viewable", func() { 14 Context("when the job is publically viewable", func() { 15 BeforeEach(func() { 16 config = atc.Config{ 17 Jobs: atc.JobConfigs{ 18 { 19 Name: "some-job", 20 Public: true, 21 }, 22 }, 23 } 24 }) 25 26 It("returns true", func() { 27 public, _ := config.JobIsPublic("some-job") 28 Expect(public).To(BeTrue()) 29 }) 30 31 It("does not error", func() { 32 _, err := config.JobIsPublic("some-job") 33 Expect(err).NotTo(HaveOccurred()) 34 }) 35 }) 36 37 Context("when the job is not publically viewable", func() { 38 BeforeEach(func() { 39 config = atc.Config{ 40 Jobs: atc.JobConfigs{ 41 { 42 Name: "some-job", 43 Public: false, 44 }, 45 }, 46 } 47 }) 48 49 It("returns false", func() { 50 public, _ := config.JobIsPublic("some-job") 51 Expect(public).To(BeFalse()) 52 }) 53 54 It("does not error", func() { 55 _, err := config.JobIsPublic("some-job") 56 Expect(err).NotTo(HaveOccurred()) 57 }) 58 }) 59 60 Context("when the job with the given name can't be found", func() { 61 BeforeEach(func() { 62 config = atc.Config{ 63 Jobs: atc.JobConfigs{ 64 { 65 Name: "some-job", 66 Public: false, 67 }, 68 }, 69 } 70 }) 71 72 It("errors", func() { 73 _, err := config.JobIsPublic("does-not-exist") 74 Expect(err).To(HaveOccurred()) 75 }) 76 }) 77 }) 78 })