mirror of https://github.com/golang/go.git
testing/fstest: return base name from mapfs FileInfo.Name
Change-Id: I5a68389a68875dbb2f6875de3f64f63dd7ca1af7 Reviewed-on: https://go-review.googlesource.com/c/go/+/565055 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
a3c35430fc
commit
ff0b46cfbb
|
|
@ -150,7 +150,7 @@ type mapFileInfo struct {
|
|||
f *MapFile
|
||||
}
|
||||
|
||||
func (i *mapFileInfo) Name() string { return i.name }
|
||||
func (i *mapFileInfo) Name() string { return path.Base(i.name) }
|
||||
func (i *mapFileInfo) Size() int64 { return int64(len(i.f.Data)) }
|
||||
func (i *mapFileInfo) Mode() fs.FileMode { return i.f.Mode }
|
||||
func (i *mapFileInfo) Type() fs.FileMode { return i.f.Mode.Type() }
|
||||
|
|
|
|||
|
|
@ -45,3 +45,15 @@ a/b.txt: -rw-rw-rw-
|
|||
t.Errorf("MapFS modes want:\n%s\ngot:\n%s\n", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMapFSFileInfoName(t *testing.T) {
|
||||
m := MapFS{
|
||||
"path/to/b.txt": &MapFile{},
|
||||
}
|
||||
info, _ := m.Stat("path/to/b.txt")
|
||||
want := "b.txt"
|
||||
got := info.Name()
|
||||
if want != got {
|
||||
t.Errorf("MapFS FileInfo.Name want:\n%s\ngot:\n%s\n", want, got)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue