Expect(string(contents)).To(Equal("three")) fileInfo, err = os.Stat(filepath.Join(tmpDir, "ddd")) Expect(err).NotTo(HaveOccurred()) Expect(fileInfo.Mode().Perm()).To(Equal(os.FileMode(0777))) }) }) Describe("#IsZipFile", func() { It("accepts zip files", func() { minimalZipBytes := []byte{'P', 'K', 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} tmpFile, err := ioutil.TempFile(os.TempDir(), "emptyzip") Expect(err).NotTo(HaveOccurred()) Expect(ioutil.WriteFile(tmpFile.Name(), minimalZipBytes, 0700)).To(Succeed()) defer os.Remove(tmpFile.Name()) Expect(zipper.IsZipFile(tmpFile.Name())).To(BeTrue()) }) It("rejects non-zip files", func() { tmpFile, err := ioutil.TempFile(os.TempDir(), "badzip") Expect(err).NotTo(HaveOccurred()) Expect(ioutil.WriteFile(tmpFile.Name(), []byte("I promise I'm a zip file"), 0700)).To(Succeed()) defer os.Remove(tmpFile.Name()) Expect(zipper.IsZipFile(tmpFile.Name())).To(BeFalse()) }) }) })