Example #1
0
			It("uploads the file to the bucket", func() {
				Expect(dropletRunner.UploadBits("droplet-name", tmpFile.Name())).To(Succeed())

				Expect(fakeBlobStore.UploadCallCount()).To(Equal(1))
				path, contents := fakeBlobStore.UploadArgsForCall(0)
				Expect(path).To(Equal("droplet-name/bits.zip"))
				Expect(ioutil.ReadAll(contents)).To(Equal([]byte("some contents")))
			})

			It("returns an error when we fail to open the droplet bits", func() {
				err := dropletRunner.UploadBits("droplet-name", "some non-existent file")
				Expect(err).To(MatchError("open some non-existent file: no such file or directory"))
			})

			It("returns an error when the upload fails", func() {
				fakeBlobStore.UploadReturns(errors.New("some error"))

				err := dropletRunner.UploadBits("droplet-name", tmpFile.Name())
				Expect(err).To(MatchError("some error"))
			})
		})
	})

	Describe("BuildDroplet", func() {
		It("does the build droplet task", func() {
			config.SetBlobStore("blob-host", "7474", "dav-user", "dav-pass")
			Expect(config.Save()).To(Succeed())

			blobURL := fmt.Sprintf("http://%s:%s@%s:%s%s",
				config.BlobStore().Username,
				config.BlobStore().Password,