Fingerprint: "fake-job-fingerprint", SHA1: "fake-job-sha", ExtractedPath: "/extracted/release/extracted_jobs/fake-job", Templates: map[string]string{"some_template": "some_file"}, PackageNames: []string{"fake-package"}, Packages: []*birelpkg.Package{expectedPackage}, Properties: map[string]bireljob.PropertyDefinition{}, }, })) Expect(release.Packages()).To(Equal([]*birelpkg.Package{expectedPackage})) }) }) Context("when the package cannot be extracted", func() { BeforeEach(func() { compressor.DecompressFileToDirErr = errors.New("Extracting package 'fake-package'") }) It("returns errors for each invalid package", func() { _, err := reader.Read() Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Extracting package 'fake-package'")) }) }) }) Context("when the jobs in the release are not valid", func() { BeforeEach(func() { fakeFs.WriteFileString( "/extracted/release/release.MF", `---
err := extractor.Extract(blobID, blobSHA1, targetDir) Expect(err).ToNot(HaveOccurred()) Expect(fs.FileExists(targetDir)).To(BeTrue()) Expect(compressor.DecompressFileToDirTarballPaths).To(ContainElement(fileName)) }) It("does not re-create the target package dir", func() { fs.MkdirAllError = fakeError err := extractor.Extract(blobID, blobSHA1, targetDir) Expect(err).ToNot(HaveOccurred()) }) Context("and decompressing the blob fails", func() { It("returns an error and doesn't remove the target dir", func() { compressor.DecompressFileToDirErr = fakeError Expect(fs.FileExists(targetDir)).To(BeTrue()) err := extractor.Extract(blobID, blobSHA1, targetDir) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(Equal("Decompressing compiled package: BlobID: 'fake-blob-id', BlobSHA1: 'fake-sha1': Initial error")) Expect(fs.FileExists(targetDir)).To(BeTrue()) }) }) }) Context("when getting the blob from the blobstore errors", func() { BeforeEach(func() { blobstore.GetError = fakeError }) It("returns an error", func() {
}) Context("when the job manifest is invalid", func() { It("returns an error when the job manifest is missing", func() { _, err := reader.Read() Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Reading job manifest")) }) It("returns an error when the job manifest is invalid", func() { fakeFs.WriteFileString("/extracted/job/job.MF", "{") _, err := reader.Read() Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Parsing job manifest")) }) }) }) Context("when the job archive is not a valid tar", func() { BeforeEach(func() { compressor.DecompressFileToDirErr = bosherr.Error("fake-error") }) It("returns error", func() { _, err := reader.Read() Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Extracting job archive '/some/job/archive'")) }) }) })
CloudProperties: biproperty.Map{ "infrastructure": "aws", "ami": biproperty.Map{ "us-east-1": "fake-ami-version", }, }, }, "fake-extracted-path", fs, ) Expect(stemcell).To(Equal(expectedStemcell)) }) Context("when extracting stemcell fails", func() { BeforeEach(func() { compressor.DecompressFileToDirErr = errors.New("fake-decompress-error") }) It("returns an error", func() { _, err := stemcellReader.Read("fake-stemcell-path", "fake-extracted-path") Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("fake-decompress-error")) }) }) Context("when reading stemcell manifest fails", func() { BeforeEach(func() { fs.ReadFileError = errors.New("fake-read-error") }) It("returns an error", func() {