Added a test for directory link behavior.

geesefs-0-30-9
Aaron Jacobs 2015-03-06 22:39:45 -06:00
parent f412eaa60a
commit 5b07c5da52
2 changed files with 16 additions and 3 deletions

View File

@ -114,9 +114,6 @@ type FileSystem interface {
// The file system is responsible for checking that the directory is empty.
//
// Sample implementation in ext2: ext2_rmdir (http://goo.gl/B9QmFf)
//
// TODO(jacobsa): Add tests for the assertion about directory link counts
// above (on a real file system and on memfs).
RmDir(
ctx context.Context,
req *RmDirRequest) (*RmDirResponse, error)

View File

@ -24,6 +24,7 @@ import (
"path"
"testing"
. "github.com/jacobsa/oglematchers"
. "github.com/jacobsa/ogletest"
)
@ -297,3 +298,18 @@ func (t *PosixTest) ReadsPastEndOfFile() {
ExpectEq(0, n)
ExpectEq("", string(buf[:n]))
}
func (t *PosixTest) HardLinkDirectory() {
dirName := path.Join(t.dir, "dir")
// Create a directory.
err := os.Mkdir(dirName, 0700)
AssertEq(nil, err)
// Attempt to hard-link it to a new name.
err = os.Link(dirName, path.Join(t.dir, "other"))
AssertNe(nil, err)
ExpectThat(err, Error(HasSubstr("link")))
ExpectThat(err, Error(HasSubstr("not permitted")))
}