示例#1
0
			Expect(res).To(Equal([]byte("aaa")))
		})

		It("returns an error if it can't write to the file", func() {
			requester.GetProductDownloadUrlReturns(server.URL(), nil)
			err := file.Chmod(0444)

			Expect(err).ToNot(HaveOccurred())
			err = api.Download(&resource.ProductFile{}, file.Name())
			Expect(err).To(HaveOccurred())
		})
	})

	Context("GetVersionsForProduct", func() {
		It("Returns an error if the product is empty", func() {
			versions, err := api.GetVersionsForProduct("")
			Expect(err).To(HaveOccurred())
			Expect(versions).To(BeEmpty())
		})

		It("returns an error if it can't get the product from the server", func() {
			requester.GetProductReturns(nil, errors.New("err"))

			versions, err := api.GetVersionsForProduct("NonexistentProduct")
			Expect(err).To(HaveOccurred())
			Expect(versions).To(BeEmpty())
		})

		It("returns the list of versions for that product", func() {
			versions, err := api.GetVersionsForProduct("ExistingProduct")
			Expect(err).ToNot(HaveOccurred())