func describeDummyPlatform() { var ( platform Platform collector boshstats.Collector fs boshsys.FileSystem cmdRunner boshsys.CmdRunner dirProvider boshdirs.Provider devicePathResolver boshdpresolv.DevicePathResolver logger boshlog.Logger ) BeforeEach(func() { collector = &fakestats.FakeCollector{} fs = fakesys.NewFakeFileSystem() cmdRunner = fakesys.NewFakeCmdRunner() dirProvider = boshdirs.NewProvider("/fake-dir") devicePathResolver = fakedpresolv.NewFakeDevicePathResolver() logger = boshlog.NewLogger(boshlog.LevelNone) }) JustBeforeEach(func() { platform = NewDummyPlatform( collector, fs, cmdRunner, dirProvider, devicePathResolver, logger, ) }) Describe("GetDefaultNetwork", func() { It("returns the contents of dummy-defaults-network-settings.json since that's what the dummy cpi writes", func() { settingsFilePath := "/fake-dir/bosh/dummy-default-network-settings.json" fs.WriteFileString(settingsFilePath, `{"IP": "1.2.3.4"}`) network, err := platform.GetDefaultNetwork() Expect(err).NotTo(HaveOccurred()) Expect(network.IP).To(Equal("1.2.3.4")) }) }) Describe("GetCertManager", func() { It("returs a dummy cert manager", func() { certManager := platform.GetCertManager() Expect(certManager.UpdateCertificates("")).Should(BeNil()) }) }) }
Expect(cmdRunner.RunCommands[0]).To(Equal( []string{ "tar", "--same-owner", "-xzvf", tarballPath, "-C", dstDir, }, )) }) }) Describe("CleanUp", func() { It("removes tarball path", func() { fs := fakesys.NewFakeFileSystem() compressor := NewTarballCompressor(cmdRunner, fs) err := fs.WriteFileString("/fake-tarball.tar", "") Expect(err).ToNot(HaveOccurred()) err = compressor.CleanUp("/fake-tarball.tar") Expect(err).ToNot(HaveOccurred()) Expect(fs.FileExists("/fake-tarball.tar")).To(BeFalse()) }) It("returns error if removing tarball path fails", func() { fs := fakesys.NewFakeFileSystem() compressor := NewTarballCompressor(cmdRunner, fs) fs.RemoveAllError = errors.New("fake-remove-all-err") err := compressor.CleanUp("/fake-tarball.tar")
BeforeEach(func() { fs = boshsys.NewOsFileSystem(logger) cmdRunner = boshsys.NewExecCmdRunner(logger) compressor = boshcmd.NewTarballCompressor(cmdRunner, fs) renderedJobListCompressor = NewRenderedJobListCompressor(fs, compressor, fakeSHA1Calculator, logger) }) It("copies rendered jobs into a new temp dir, compresses the temp dir, and wraps it in a RenderedJobListArchive", func() { // create rendered job with 2 rendered scripts renderedJobDir0, err := fs.TempDir("RenderedJobListCompressorTest") Expect(err).ToNot(HaveOccurred()) renderedJob0 := NewRenderedJob(bireljob.Job{Name: "fake-job-name-0"}, renderedJobDir0, fs, logger) defer func() { err := renderedJob0.Delete(); Expect(err).ToNot(HaveOccurred()) }() err = fs.WriteFileString(filepath.Join(renderedJobDir0, "script-0"), "fake-rendered-job-0-script-0-content") Expect(err).ToNot(HaveOccurred()) err = fs.WriteFileString(filepath.Join(renderedJobDir0, "script-1"), "fake-rendered-job-0-script-1-content") Expect(err).ToNot(HaveOccurred()) renderedJobList.Add(renderedJob0) // create another rendered job with 1 rendered script renderedJobDir1, err := fs.TempDir("RenderedJobListCompressorTest") Expect(err).ToNot(HaveOccurred()) renderedJob1 := NewRenderedJob(bireljob.Job{Name: "fake-job-name-1"}, renderedJobDir1, fs, logger) defer func() { err := renderedJob1.Delete(); Expect(err).ToNot(HaveOccurred()) }() err = fs.WriteFileString(filepath.Join(renderedJobDir1, "script-0"), "fake-rendered-job-1-script-0-content") Expect(err).ToNot(HaveOccurred()) renderedJobList.Add(renderedJob1) // compress
func GenerateDeploymentManifest(deploymentManifestFilePath string, fs boshsys.FileSystem, manifestContents string) error { return fs.WriteFileString(deploymentManifestFilePath, manifestContents) }