var versionInfo *exec.VersionInfo

			BeforeEach(func() {
				versionInfo = &exec.VersionInfo{
					Version:  atc.Version{"result": "version"},
					Metadata: []atc.MetadataField{{"result", "metadata"}},
				}
			})

			Context("when exit status is not 0", func() {
				JustBeforeEach(func() {
					inputDelegate.Completed(exec.ExitStatus(12), versionInfo)
				})

				It("saves the build's input", func() {
					Ω(fakeDB.SaveBuildInputCallCount()).Should(Equal(1))

					buildID, savedInput := fakeDB.SaveBuildInputArgsForCall(0)
					Ω(buildID).Should(Equal(42))
					Ω(savedInput).Should(Equal(db.BuildInput{
						Name: "some-input",
						VersionedResource: db.VersionedResource{
							PipelineName: "some-pipeline",
							Resource:     "some-input-resource",
							Type:         "some-type",
							Version:      db.Version{"result": "version"},
							Metadata:     []db.MetadataField{{"result", "metadata"}},
						},
					}))
				})
			var versionInfo *exec.VersionInfo

			BeforeEach(func() {
				versionInfo = &exec.VersionInfo{
					Version:  atc.Version{"result": "version"},
					Metadata: []atc.MetadataField{{"result", "metadata"}},
				}
			})

			Context("when exit status is not 0", func() {
				JustBeforeEach(func() {
					inputDelegate.Completed(exec.ExitStatus(12), nil)
				})

				It("does not save the build's input", func() {
					Expect(fakeDB.SaveBuildInputCallCount()).To(Equal(0))
				})

				It("saves a finish-get event", func() {
					Expect(fakeDB.SaveBuildEventCallCount()).To(Equal(1))

					buildID, savedEvent := fakeDB.SaveBuildEventArgsForCall(0)
					Expect(buildID).To(Equal(42))
					Expect(savedEvent).To(Equal(event.FinishGet{
						Origin: event.Origin{
							Type:     event.OriginTypeGet,
							Name:     "some-input",
							Location: location,
						},
						Plan: event.GetPlan{
							Name:     "some-input",