Exemplo n.º 1
0
			defer f.Close()
			Expect(h.Name).To(Equal("subfolder/sub"))
			Expect(h.FileInfo().Mode()).To(Equal(os.FileMode(0644)))
			Expect(f.Read(buffer)).To(Equal(12))
			Expect(string(buffer)).To(Equal("sub contents"))
		})

		Context("failure", func() {
			It("returns an error if passed a non-directory", func() {
				_, err := zipper.Zip(filepath.Join(tmpDir, "aaa"), fakeCFIgnore)
				Expect(err).To(MatchError(fmt.Sprintf("%s must be a directory", filepath.Join(tmpDir, "aaa"))))
			})

			It("returns an error if .cfignore can't be parsed", func() {
				Expect(ioutil.WriteFile(filepath.Join(tmpDir, ".cfignore"), []byte{}, 0600)).To(Succeed())
				fakeCFIgnore.ParseReturns(errors.New("no"))
				_, err := zipper.Zip(tmpDir, fakeCFIgnore)
				Expect(err).To(MatchError("no"))
			})
		})
	})

	Describe("#Unzip", func() {
		var (
			prevDir, tmpDir string
			err             error
			tmpFile         *os.File
			prevUmask       int
		)

		BeforeEach(func() {