コード例 #1
0
ファイル: db_volumes_test.go プロジェクト: pcfdev-forks/atc
			err = database.InsertVolume(volume5)
			Expect(err).NotTo(HaveOccurred())
			err = database.SaveImageResourceVersion(jobBuild.ID, "plan-id-5", volume5.VolumeIdentifier)
			Expect(err).NotTo(HaveOccurred())

			// To show that it reaps expired volumes
			volume6 := db.Volume{
				WorkerName: "worker-6",
				TTL:        -time.Hour,
				Handle:     "volume-6",
				VolumeIdentifier: db.VolumeIdentifier{
					ResourceVersion: atc.Version{"digest": "digest-6"},
					ResourceHash:    `docker:{"repository":"repository-6"}`,
				},
			}
			err = database.InsertVolume(volume6)
			Expect(err).NotTo(HaveOccurred())
			err = database.SaveImageResourceVersion(oneOffBuildA.ID, "plan-id-6", volume6.VolumeIdentifier)
			Expect(err).NotTo(HaveOccurred())

			actualSavedVolumes, err := database.GetVolumesForOneOffBuildImageResources()
			Expect(err).NotTo(HaveOccurred())
			var actualVolumes []db.Volume
			for _, actualSavedVolume := range actualSavedVolumes {
				actualVolumes = append(actualVolumes, actualSavedVolume.Volume)
			}
			Expect(actualVolumes).To(ConsistOf(volume1, volume2, volume3, volume4))
		})
	})
})