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>
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() }
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)
+ }
+}