func (r releaseRepo) Update(releases []release.Release) error { newRecordIDs := []string{} newRecords := []ReleaseRecord{} deploymentState, err := r.deploymentStateService.Load() if err != nil { return bosherr.WrapError(err, "Loading existing config") } for _, release := range releases { newRecord := ReleaseRecord{ Name: release.Name(), Version: release.Version(), } newRecord.ID, err = r.uuidGenerator.Generate() if err != nil { return bosherr.WrapError(err, "Generating release id") } newRecords = append(newRecords, newRecord) newRecordIDs = append(newRecordIDs, newRecord.ID) } deploymentState.CurrentReleaseIDs = newRecordIDs deploymentState.Releases = newRecords err = r.deploymentStateService.Save(deploymentState) if err != nil { return bosherr.WrapError(err, "Updating current release record") } return nil }
}) Context("when the packages in the release are valid", func() { It("returns a release from the given tar file", func() { release, err := reader.Read() Expect(err).NotTo(HaveOccurred()) expectedPackage := &birelpkg.Package{ Name: "fake-package", Fingerprint: "fake-package-fingerprint", SHA1: "fake-package-sha", Dependencies: []*birelpkg.Package{&birelpkg.Package{Name: "fake-package-1"}}, ExtractedPath: "/extracted/release/extracted_packages/fake-package", ArchivePath: "/extracted/release/packages/fake-package.tgz", } Expect(release.Name()).To(Equal("fake-release")) Expect(release.Version()).To(Equal("fake-version")) Expect(release.Jobs()).To(Equal([]bireljob.Job{ { Name: "fake-job", 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})) })