return fmt.Sprintf("Expected `%s' to not be a directory", actual) } var _ = Describe("tarballCompressor", func() { var ( dstDir string cmdRunner boshsys.CmdRunner fs boshsys.FileSystem compressor Compressor ) BeforeEach(func() { logger := boshlog.NewLogger(boshlog.LevelNone) cmdRunner = boshsys.NewExecCmdRunner(logger) fs = boshsys.NewOsFileSystem(logger) tmpDir, err := fs.TempDir("tarballCompressor-test") Expect(err).NotTo(HaveOccurred()) dstDir = filepath.Join(tmpDir, "TestCompressor") compressor = NewTarballCompressor(cmdRunner, fs) }) BeforeEach(func() { fs.MkdirAll(dstDir, os.ModePerm) }) AfterEach(func() { fs.RemoveAll(dstDir) }) Describe("CompressFilesInDir", func() { It("compresses the files in the given directory", func() {
cmdRunner boshsys.CmdRunner compressor boshcmd.Compressor ) 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")