예제 #1
0
			Expect(actualFs).To(Equal(fs))
			Expect(path).To(Equal(installPath))

			otherSourcePath := createSourcePath()

			actualFs, path, err = fileBundle.Install(otherSourcePath)
			Expect(err).NotTo(HaveOccurred())
			Expect(actualFs).To(Equal(fs))
			Expect(path).To(Equal(installPath))

			Expect(fs.RenameOldPaths[0]).To(Equal(sourcePath))
			Expect(fs.RenameNewPaths[0]).To(Equal(installPath))
		})

		It("returns error when moving source to install path fails", func() {
			fs.RenameError = errors.New("fake-rename-error")

			_, _, err := fileBundle.Install(sourcePath)
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("fake-rename-error"))
		})

		It("returns error when it fails to change permissions", func() {
			fs.ChmodErr = errors.New("fake-chmod-error")

			_, _, err := fileBundle.Install(sourcePath)
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("fake-chmod-error"))
		})

		It("does not install bundle if it fails to change permissions", func() {
예제 #2
0
		Expect(fs.FileExists(newLocation)).To(BeFalse())

		err := mover.Move(oldLocation, newLocation)
		Expect(err).ToNot(HaveOccurred())

		Expect(fs.FileExists(oldLocation)).To(BeFalse())

		contents, err := fs.ReadFileString(newLocation)
		Expect(err).ToNot(HaveOccurred())
		Expect(contents).To(Equal("some content"))
	})

	Context("when Rename fails due to EXDEV error", func() {
		BeforeEach(func() {
			fs.RenameError = &os.LinkError{
				Err: syscall.Errno(0x12),
			}
		})

		It("moves the file", func() {
			Expect(fs.FileExists(oldLocation)).To(BeTrue())
			Expect(fs.FileExists(newLocation)).To(BeFalse())

			err := mover.Move(oldLocation, newLocation)
			Expect(err).ToNot(HaveOccurred())

			Expect(fs.FileExists(oldLocation)).To(BeFalse())

			contents, err := fs.ReadFileString(newLocation)
			Expect(err).ToNot(HaveOccurred())
			Expect(contents).To(Equal("some content"))