Added a test for directory link behavior.
parent
f412eaa60a
commit
5b07c5da52
|
@ -114,9 +114,6 @@ type FileSystem interface {
|
||||||
// The file system is responsible for checking that the directory is empty.
|
// The file system is responsible for checking that the directory is empty.
|
||||||
//
|
//
|
||||||
// Sample implementation in ext2: ext2_rmdir (http://goo.gl/B9QmFf)
|
// 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(
|
RmDir(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *RmDirRequest) (*RmDirResponse, error)
|
req *RmDirRequest) (*RmDirResponse, error)
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/jacobsa/oglematchers"
|
||||||
. "github.com/jacobsa/ogletest"
|
. "github.com/jacobsa/ogletest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -297,3 +298,18 @@ func (t *PosixTest) ReadsPastEndOfFile() {
|
||||||
ExpectEq(0, n)
|
ExpectEq(0, n)
|
||||||
ExpectEq("", string(buf[: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")))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue