Пример #1
0
			cpiPackage := birelpkg.Package{
				Name:          "fake-package-name",
				Fingerprint:   "fake-package-fingerprint-cpi",
				SHA1:          "fake-package-sha1-cpi",
				Dependencies:  []*birelpkg.Package{},
				ExtractedPath: "fake-package-extracted-path-cpi",
				ArchivePath:   "fake-package-archive-path-cpi",
			}
			cpiRelease := birel.NewRelease(
				"fake-cpi-release-name",
				"1.1",
				[]bireljob.Job{
					{
						Name: "fake-cpi-release-job-name",
						Templates: map[string]string{
							"cpi.erb": "bin/cpi",
						},
						Packages: []*birelpkg.Package{&cpiPackage},
					},
				},
				[]*birelpkg.Package{&cpiPackage},
				"fake-cpi-extracted-dir",
				fs,
			)
			mockReleaseExtractor.EXPECT().Extract("/fake-cpi-release.tgz").Do(func(_ string) {
				err := fs.MkdirAll("fake-cpi-extracted-dir", os.ModePerm)
				Expect(err).ToNot(HaveOccurred())
			}).Return(cpiRelease, nil).AnyTimes()

			installationManifest := biinstallmanifest.Manifest{
				Name: "test-deployment",
				Template: biinstallmanifest.ReleaseJobRef{
`)
		}

		var writeCPIReleaseTarball = func() {
			fs.WriteFileString("/fake-cpi-release.tgz", "fake-tgz-content")
		}

		var allowCPIToBeExtracted = func() {
			cpiRelease := birel.NewRelease(
				"fake-cpi-release-name",
				"fake-cpi-release-version",
				[]bireljob.Job{
					{
						Name: "fake-cpi-release-job-name",
						Templates: map[string]string{
							"templates/cpi.erb": "bin/cpi",
						},
					},
				},
				[]*birelpkg.Package{},
				"fake-cpi-extracted-dir",
				fs,
				false,
			)

			expectCPIExtractRelease = mockReleaseExtractor.EXPECT().Extract("/fake-cpi-release.tgz").Do(func(_ string) {
				err := fs.MkdirAll("fake-cpi-extracted-dir", os.ModePerm)
				Expect(err).ToNot(HaveOccurred())
			}).Return(cpiRelease, nil).AnyTimes()
		}

		var allowCPIToBeInstalled = func() {
Пример #3
0
	)

	BeforeEach(func() {
		fakeFs = fakesys.NewFakeFileSystem()
	})

	It("validates a valid release without error", func() {
		release := birel.NewRelease(
			"fake-release-name",
			"fake-release-version",
			[]bireljob.Job{
				{
					Name:        "fake-cpi-release-job-name",
					Fingerprint: "fake-job-1-fingerprint",
					SHA1:        "fake-job-1-sha",
					Templates: map[string]string{
						"cpi.erb": "bin/cpi",
					},
				},
			},
			[]*birelpkg.Package{},
			"/some/release/path",
			fakeFs,
			false,
		)
		validator := NewValidator()

		err := validator.Validate(release, cpiReleaseJobName)
		Expect(err).NotTo(HaveOccurred())
	})

	Context("when the cpi job is not present", func() {