コード例 #1
0
	})

	AfterEach(func() {
		// don't check for error!
		fs.RemoveAll(rootPath)
		fs.Remove(LongPath)
	})

	// TODO: make sure we can cleanup before running tests
	It("the fs package can cleanup long paths and dirs", func() {
		f, err := fs.Create(LongPath)
		Expect(err).To(Succeed())
		f.Close()
		Expect(fs.Remove(LongPath)).To(Succeed())

		Expect(fs.MkdirAll(LongDir, 0755)).To(Succeed())
		Expect(fs.RemoveAll(LongDir)).To(Succeed())
	})

	It("can create and delete a directory with a long path", func() {
		Expect(osFs.MkdirAll(LongDir, 0755)).To(Succeed())
		Expect(osFs.RemoveAll(LongDir)).To(Succeed())

		dir := filepath.Join(LongDir, "NEW_DIR")
		Expect(osFs.MkdirAll(dir, 0755)).To(Succeed())

		path := filepath.Join(dir, "a.txt")
		Expect(osFs.WriteFileString(path, "abc")).To(Succeed())
	})

	It("can create and delete a file with a long path", func() {
コード例 #2
0
ファイル: os_file_system.go プロジェクト: mattcui/bosh-agent
func (fs *osFileSystem) MkdirAll(path string, perm os.FileMode) (err error) {
	fs.logger.Debug(fs.logTag, "Making dir %s with perm %#o", path, perm)
	return fsWrapper.MkdirAll(path, perm)
}
コード例 #3
0
var _ = Describe("Windows Specific tests", func() {
	It("HomeDir returns an error if 'username' is not the current user", func() {
		if !Windows {
			Skip("Windows only test")
		}
		osFs := createOsFs()

		_, err := osFs.HomeDir("Non-Existent User Name 1234")
		Expect(err).To(HaveOccurred())
	})

	It("can remove a directory long path", func() {
		osFs := createOsFs()

		rootPath, longPath := randLongPath()
		err := fsWrapper.MkdirAll(longPath, 0755)
		defer fsWrapper.RemoveAll(rootPath)
		Expect(err).ToNot(HaveOccurred())

		dstFile, err := ioutil.TempFile(`\\?\`+longPath, "")
		Expect(err).ToNot(HaveOccurred())

		dstPath := path.Join(longPath, filepath.Base(dstFile.Name()))
		defer os.Remove(dstPath)
		dstFile.Close()

		fileInfo, err := osFs.Stat(dstPath)
		Expect(fileInfo).ToNot(BeNil())
		Expect(os.IsNotExist(err)).To(BeFalse())

		err = osFs.RemoveAll(dstPath)