Пример #1
0
		fakeProxyConfReader = &fake_proxyconf_reader.FakeProxyConfReader{}
		dropletRunner = droplet_runner.New(fakeAppRunner, fakeTaskRunner, config, fakeBlobStore, fakeAppExaminer, fakeProxyConfReader)
	})

	Describe("ListDroplets", func() {
		It("returns a list of droplets in the blob store", func() {
			fakeBlobStore.ListReturns([]blob.Blob{
				{Path: "X/bits.zip", Created: time.Unix(1000, 0), Size: 100},
				{Path: "X/droplet.tgz", Created: time.Unix(2000, 0), Size: 200},
				{Path: "X/result.json", Created: time.Unix(3000, 0), Size: 300},
				{Path: "Y/bits.zip"},
				{Path: "X/Y/droplet.tgz"},
				{Path: "droplet.tgz"},
			}, nil)

			Expect(dropletRunner.ListDroplets()).To(Equal([]droplet_runner.Droplet{
				{Name: "X", Created: time.Unix(2000, 0), Size: 200},
			}))
		})

		It("returns an error when querying the blob store fails", func() {
			fakeBlobStore.ListReturns(nil, errors.New("some error"))

			_, err := dropletRunner.ListDroplets()
			Expect(err).To(MatchError("some error"))
		})
	})

	Describe("UploadBits", func() {
		Context("when the archive path is a file and exists", func() {
			var tmpFile *os.File
Пример #2
0
				case "Z/":
					return &s3.ListResp{
						Name:      "bucket-name",
						Prefix:    "Z/",
						Delimiter: "/",
						Contents: []s3.Key{
							s3.Key{Key: "Z/bits.tgz"},
						},
					}, nil
				}

				Fail("no stub for arguments: " + prefix + "," + delim + "," + marker + "," + string(max))
				return nil, nil
			}

			droplets, err := dropletRunner.ListDroplets()

			Expect(err).NotTo(HaveOccurred())
			Expect(len(droplets)).To(Equal(2))
			Expect(droplets[0].Name).To(Equal("X"))
			Expect(droplets[0].Created.Unix()).To(Equal(time.Date(2006, 1, 2, 15, 4, 5, 999, time.UTC).Unix()))
			Expect(droplets[0].Size).To(Equal(int64(200)))
			Expect(droplets[1].Name).To(Equal("Y"))
			Expect(droplets[1].Created).To(BeZero())
			Expect(droplets[1].Size).To(Equal(int64(0)))
		})

		It("returns an error when querying the blob store fails", func() {
			config.SetBlobTarget("blob-host", 7474, "access-key", "secret-key", "bucket-name")
			config.Save()