1
2
3
4
5 package fstest
6
7 import (
8 "internal/testenv"
9 "os"
10 "path/filepath"
11 "testing"
12 )
13
14 func TestSymlink(t *testing.T) {
15 testenv.MustHaveSymlink(t)
16
17 tmp := t.TempDir()
18 tmpfs := os.DirFS(tmp)
19
20 if err := os.WriteFile(filepath.Join(tmp, "hello"), []byte("hello, world\n"), 0644); err != nil {
21 t.Fatal(err)
22 }
23
24 if err := os.Symlink(filepath.Join(tmp, "hello"), filepath.Join(tmp, "hello.link")); err != nil {
25 t.Fatal(err)
26 }
27
28 if err := TestFS(tmpfs, "hello", "hello.link"); err != nil {
29 t.Fatal(err)
30 }
31 }
32
33 func TestDash(t *testing.T) {
34 m := MapFS{
35 "a-b/a": {Data: []byte("a-b/a")},
36 }
37 if err := TestFS(m, "a-b/a"); err != nil {
38 t.Error(err)
39 }
40 }
41
View as plain text