github.com/rafaeltorres324/go/src@v0.0.0-20210519164414-9fdf653a9838/testing/fstest/testfs_test.go (about)

     1  // Copyright 2021 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     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  }