コード例 #1
0
ファイル: basics_test.go プロジェクト: Richardphp/noms
func (s *fuseTestSuite) TestRename() {
	datasetName := "TestRename"
	str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)

	var testfs pathfs.FileSystem

	start(str, func(fs pathfs.FileSystem) { testfs = fs })

	_, code := testfs.Create("prince", uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0644, nil)
	assert.Equal(s.T(), fuse.OK, code)
	code = testfs.Rename("prince", "O(+>", nil)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "O(+>", 0644|fuse.S_IFREG, 0)
}
コード例 #2
0
ファイル: dir_test.go プロジェクト: Richardphp/noms
func (s *fuseTestSuite) TestRenameWhileOpen() {
	datasetName := "TestRenameWhileOpen"
	str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)

	var testfs pathfs.FileSystem

	start(str, func(fs pathfs.FileSystem) { testfs = fs })

	code := testfs.Mkdir("foo", 0755, nil)
	assert.Equal(s.T(), fuse.OK, code)
	code = testfs.Mkdir("foo/bar", 0755, nil)
	assert.Equal(s.T(), fuse.OK, code)
	file, code := testfs.Create("foo/bar/file.txt", uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0644, nil)
	assert.Equal(s.T(), fuse.OK, code)

	// Validate renaming a file between opening it and writing to it.
	code = testfs.Rename("foo/bar/file.txt", "file.txt", nil)
	assert.Equal(s.T(), fuse.OK, code)

	n, code := file.Write([]byte("howdy!"), 0)
	assert.Equal(s.T(), uint32(6), n)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "file.txt", 0644|fuse.S_IFREG, 6)
}
コード例 #3
0
ファイル: dir_test.go プロジェクト: Richardphp/noms
func (s *fuseTestSuite) TestRenaming() {
	datasetName := "TestRenaming"
	str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)

	var testfs pathfs.FileSystem

	start(str, func(fs pathfs.FileSystem) { testfs = fs })

	code := testfs.Mkdir("foo", 0755, nil)
	assert.Equal(s.T(), fuse.OK, code)
	code = testfs.Mkdir("foo/bar", 0755, nil)
	assert.Equal(s.T(), fuse.OK, code)
	code = testfs.Mkdir("foo/baz", 0755, nil)
	assert.Equal(s.T(), fuse.OK, code)
	_, code = testfs.Create("foo/bar/buzz", uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0644, nil)
	assert.Equal(s.T(), fuse.OK, code)

	code = testfs.Rename("foo/bar/buzz", "foo/baz/buzz", nil)
	assert.Equal(s.T(), fuse.OK, code)
	code = testfs.Rename("foo/baz/buzz", "buzz", nil)
	assert.Equal(s.T(), fuse.OK, code)
	code = testfs.Rename("buzz", "foo/buzz", nil)
	assert.Equal(s.T(), fuse.OK, code)
}