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"}},
						},
					}))
				})

				It("saves a finish-get event", func() {
					Ω(fakeDB.SaveBuildEventCallCount()).Should(Equal(1))
								Resource:     "some-input-resource",
								Type:         "some-type",
								Version:      db.Version{"result": "version"},
								Metadata:     []db.MetadataField{{"saved", "metadata"}},
							},
						}, nil)
					})

					JustBeforeEach(func() {
						inputDelegate.Completed(exec.ExitStatus(0), versionInfo)
					})

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

						teamName, buildID, savedInput := fakeDB.SaveBuildInputArgsForCall(0)
						Expect(teamName).To(Equal(atc.DefaultTeamName))
						Expect(buildID).To(Equal(42))
						Expect(savedInput).To(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"}},
							},
						}))
					})

					It("saves a finish-get event", func() {