Exemplo n.º 1
0
				It("returns an error", func() {
					_, err := GetBuild(client, expectedJobName, expectedBuildName, expectedPipelineName)
					Expect(err).To(MatchError("build not found"))
				})
			})
		})

		Context("when nothing is passed", func() {
			expectedOneOffBuild := atc.Build{
				ID:      123,
				Name:    expectedBuildName,
				Status:  "Great Success",
				JobName: "",
				URL:     fmt.Sprintf("/builds/%s", expectedBuildID),
				APIURL:  fmt.Sprintf("api/v1/builds/%s", expectedBuildID),
			}

			BeforeEach(func() {
				client.AllBuildsReturns([]atc.Build{expectedBuild, expectedOneOffBuild}, nil)
			})

			It("returns latest one off build", func() {
				build, err := GetBuild(client, "", "", "")
				Expect(err).NotTo(HaveOccurred())
				Expect(build).To(Equal(expectedOneOffBuild))
				Expect(client.AllBuildsCallCount()).To(Equal(1))
			})
		})
	})
})
Exemplo n.º 2
0
var _ = Describe("FetchTemplateData", func() {
	var fakeClient *cfakes.FakeClient

	BeforeEach(func() {
		fakeClient = new(cfakes.FakeClient)
	})

	It("queries the database for a list of all builds", func() {
		builds := []atc.Build{
			atc.Build{
				ID: 6,
			},
		}

		fakeClient.AllBuildsReturns(builds, nil)

		templateData, err := FetchTemplateData(fakeClient)
		Expect(err).NotTo(HaveOccurred())

		Expect(templateData.Builds[0].ID).To(Equal(6))
		Expect(templateData.Builds).To(BeAssignableToTypeOf([]PresentedBuild{}))
	})

	It("returns an error if fetching from the database fails", func() {
		fakeClient.AllBuildsReturns(nil, errors.New("disaster"))

		_, err := FetchTemplateData(fakeClient)
		Expect(err).To(HaveOccurred())
	})
})