...
Source file
src/io/fs/stat_test.go
Documentation: io/fs
1
2
3
4
5 package fs_test
6
7 import (
8 "fmt"
9 . "io/fs"
10 "testing"
11 )
12
13 type statOnly struct{ StatFS }
14
15 func (statOnly) Open(name string) (File, error) { return nil, ErrNotExist }
16
17 func TestStat(t *testing.T) {
18 check := func(desc string, info FileInfo, err error) {
19 t.Helper()
20 if err != nil || info == nil || info.Mode() != 0456 {
21 infoStr := "<nil>"
22 if info != nil {
23 infoStr = fmt.Sprintf("FileInfo(Mode: %#o)", info.Mode())
24 }
25 t.Fatalf("Stat(%s) = %v, %v, want Mode:0456, nil", desc, infoStr, err)
26 }
27 }
28
29
30 info, err := Stat(statOnly{testFsys}, "hello.txt")
31 check("statOnly", info, err)
32
33
34 info, err = Stat(openOnly{testFsys}, "hello.txt")
35 check("openOnly", info, err)
36 }
37
View as plain text