Added better tests for statting new dirs.
parent
79d87d5956
commit
605a52de92
|
@ -9,6 +9,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -22,6 +23,16 @@ import (
|
||||||
|
|
||||||
func TestMemFS(t *testing.T) { RunTests(t) }
|
func TestMemFS(t *testing.T) { RunTests(t) }
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// Helpers
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
func currentUid() uint32
|
||||||
|
|
||||||
|
func currentGid() uint32
|
||||||
|
|
||||||
|
func timespecToTime(ts syscall.Timespec) time.Time
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Boilerplate
|
// Boilerplate
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -97,6 +108,8 @@ func (t *MemFSTest) ContentsOfEmptyFileSystem() {
|
||||||
func (t *MemFSTest) Mkdir() {
|
func (t *MemFSTest) Mkdir() {
|
||||||
var err error
|
var err error
|
||||||
var fi os.FileInfo
|
var fi os.FileInfo
|
||||||
|
var stat *syscall.Stat_t
|
||||||
|
|
||||||
dirName := path.Join(t.mfs.Dir(), "dir")
|
dirName := path.Join(t.mfs.Dir(), "dir")
|
||||||
|
|
||||||
// Create a directory within the root.
|
// Create a directory within the root.
|
||||||
|
@ -109,6 +122,7 @@ func (t *MemFSTest) Mkdir() {
|
||||||
|
|
||||||
// Stat the directory.
|
// Stat the directory.
|
||||||
fi, err = os.Stat(dirName)
|
fi, err = os.Stat(dirName)
|
||||||
|
stat = fi.Sys().(*syscall.Stat_t)
|
||||||
|
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
ExpectEq("dir", fi.Name())
|
ExpectEq("dir", fi.Name())
|
||||||
|
@ -117,6 +131,14 @@ func (t *MemFSTest) Mkdir() {
|
||||||
ExpectEq(0, fi.ModTime().Sub(createTime))
|
ExpectEq(0, fi.ModTime().Sub(createTime))
|
||||||
ExpectTrue(fi.IsDir())
|
ExpectTrue(fi.IsDir())
|
||||||
|
|
||||||
|
ExpectEq(1, stat.Nlink)
|
||||||
|
ExpectEq(currentUid(), stat.Uid)
|
||||||
|
ExpectEq(currentGid(), stat.Gid)
|
||||||
|
ExpectEq(0, stat.Size)
|
||||||
|
ExpectEq(createTime, timespecToTime(stat.Atimespec))
|
||||||
|
ExpectEq(createTime, timespecToTime(stat.Mtimespec))
|
||||||
|
ExpectEq(createTime, timespecToTime(stat.Ctimespec))
|
||||||
|
|
||||||
// Read the directory.
|
// Read the directory.
|
||||||
entries, err := ioutil.ReadDir(dirName)
|
entries, err := ioutil.ReadDir(dirName)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue