Debian Codegraph @

osfs/os_wasip1_test.go

raw symbols SCIP
1 //go:build wasip1
2 // +build wasip1
3
4 package osfs
5
6 import (
7 "fmt"
8 "os"
9 "path/filepath"
10 "reflect"
11 "testing"
12
13 "github.com/go-git/go-billy/v5"
14 "github.com/go-git/go-billy/v5/test"
15
16 . "gopkg.in/check.v1"
17 )
18
19 func Test(t *testing.T) { TestingT(t) }
20
21 type OSSuite struct {
22 test.FilesystemSuite
23 path string
24 tempCounter int
25 }
26
27 var _ = Suite(&OSSuite{})
28
29 func (s *OSSuite) SetUpTest(c *C) {
30 s.tempCounter++
31 s.path = fmt.Sprintf("test_%d", s.tempCounter)
32 s.FilesystemSuite = test.NewFilesystemSuite(New(s.path))
33 }
34
35 func (s *OSSuite) TestOpenDoesNotCreateDir(c *C) {
36 _, err := s.FS.Open("dir/non-existent")
37 c.Assert(err, NotNil)
38
39 _, err = s.FS.Stat(filepath.Join(s.path, "dir"))
40 c.Assert(os.IsNotExist(err), Equals, true)
41 }
42
43 func (s *OSSuite) TestCapabilities(c *C) {
44 _, ok := s.FS.(billy.Capable)
45 c.Assert(ok, Equals, true)
46
47 caps := billy.Capabilities(s.FS)
48 c.Assert(caps, Equals, billy.DefaultCapabilities)
49 }
50
51 func TestDefault(t *testing.T) {
52 want := Default
53 got := Default
54
55 if reflect.TypeOf(got) != reflect.TypeOf(want) {
56 t.Errorf("wanted Default to be %T got %T", want, got)
57 }
58 }
59
60 func TestNewAPI(t *testing.T) {
61 _ = New("/")
62 }