1package exec_test 2 3import ( 4 "github.com/concourse/concourse/atc/exec" 5 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8) 9 10var _ = Describe("StepMetadata", func() { 11 var stepMetadata exec.StepMetadata 12 13 Describe("Env", func() { 14 Context("when populating fields", func() { 15 BeforeEach(func() { 16 stepMetadata = exec.StepMetadata{ 17 BuildID: 1, 18 BuildName: "42", 19 TeamID: 2222, 20 TeamName: "some-team", 21 JobID: 3333, 22 JobName: "some-job-name", 23 PipelineID: 4444, 24 PipelineName: "some-pipeline-name", 25 ExternalURL: "http://www.example.com", 26 } 27 }) 28 29 It("returns the specified values", func() { 30 Expect(stepMetadata.Env()).To(ConsistOf( 31 "BUILD_ID=1", 32 "BUILD_NAME=42", 33 "BUILD_TEAM_ID=2222", 34 "BUILD_TEAM_NAME=some-team", 35 "BUILD_JOB_ID=3333", 36 "BUILD_JOB_NAME=some-job-name", 37 "BUILD_PIPELINE_ID=4444", 38 "BUILD_PIPELINE_NAME=some-pipeline-name", 39 "ATC_EXTERNAL_URL=http://www.example.com", 40 )) 41 }) 42 }) 43 44 Context("when fields are empty", func() { 45 BeforeEach(func() { 46 stepMetadata = exec.StepMetadata{ 47 BuildID: 1, 48 } 49 }) 50 It("does not include fields that are not set", func() { 51 Expect(stepMetadata.Env()).To(Equal([]string{ 52 "BUILD_ID=1", 53 })) 54 }) 55 }) 56 }) 57}) 58