test set_pipeline of empty pipeline config
@@ -29,6 +29,22 @@ var _ = Describe("SetPipelineStep", func() {
---
jobs:
- name:
+`
+
+ const badPipelineContentWithTaskSyntax = `
+---
+platform: linux
+image_resource:
+ type: registry-image
+ source: {repository: busybox}
+run:
+ path: echo
+ args:
+ - hello
+`
+
+ const badPipelineContentWithEmptyContent = `
+---
`
const pipelineContent = `
@@ -245,6 +261,54 @@ jobs:
})
})
+ Context("when pipeline file exists but has task syntax", func() {
+ BeforeEach(func() {
+ fakeWorkerClient.StreamFileFromArtifactReturns(&fakeReadCloser{str: badPipelineContentWithTaskSyntax}, nil)
+ })
+
+ It("should not return error", func() {
+ Expect(stepErr).NotTo(HaveOccurred())
+ })
+
+ It("should log no-diff", func() {
+ Expect(stdout).To(gbytes.Say("no diff found."))
+ })
+
+ It("should send a set pipeline changed event", func() {
+ Expect(fakeDelegate.SetPipelineChangedCallCount()).To(Equal(1))
+ _, changed := fakeDelegate.SetPipelineChangedArgsForCall(0)
+ Expect(changed).To(BeFalse())
+ })
+
+ It("should not update the job and build id", func() {
+ Expect(fakePipeline.SetParentIDsCallCount()).To(Equal(0))
+ })
+ })
+
+ Context("when pipeline file exists but is empty", func() {
+ BeforeEach(func() {
+ fakeWorkerClient.StreamFileFromArtifactReturns(&fakeReadCloser{str: badPipelineContentWithEmptyContent}, nil)
+ })
+
+ It("should not return error", func() {
+ Expect(stepErr).NotTo(HaveOccurred())
+ })
+
+ It("should log no-diff", func() {
+ Expect(stdout).To(gbytes.Say("no diff found."))
+ })
+
+ It("should send a set pipeline changed event", func() {
+ Expect(fakeDelegate.SetPipelineChangedCallCount()).To(Equal(1))
+ _, changed := fakeDelegate.SetPipelineChangedArgsForCall(0)
+ Expect(changed).To(BeFalse())
+ })
+
+ It("should not update the job and build id", func() {
+ Expect(fakePipeline.SetParentIDsCallCount()).To(Equal(0))
+ })
+ })
+
Context("when pipeline file is good", func() {
BeforeEach(func() {
fakeWorkerClient.StreamFileFromArtifactReturns(&fakeReadCloser{str: pipelineContent}, nil)
