File tree 3 files changed +42
-0
lines changed
3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ const (
18
18
defaultCreateMode = 0o666
19
19
)
20
20
21
+ // Default Filesystem representing the root of the os filesystem.
22
+ var Default = & ChrootOS {}
23
+
21
24
// New returns a new OS filesystem.
22
25
func New (baseDir string , opts ... Option ) billy.Filesystem {
23
26
o := & options {}
Original file line number Diff line number Diff line change @@ -7,9 +7,11 @@ import (
7
7
"fmt"
8
8
"os"
9
9
"path/filepath"
10
+ "reflect"
10
11
"testing"
11
12
12
13
"github.com/go-git/go-billy/v5"
14
+ "github.com/go-git/go-billy/v5/memfs"
13
15
"github.com/go-git/go-billy/v5/test"
14
16
15
17
. "gopkg.in/check.v1"
@@ -46,3 +48,16 @@ func (s *OSSuite) TestCapabilities(c *C) {
46
48
caps := billy .Capabilities (s .FS )
47
49
c .Assert (caps , Equals , billy .DefaultCapabilities &^billy .LockCapability )
48
50
}
51
+
52
+ func TestDefault (t * testing.T ) {
53
+ want := & memfs.Memory {}
54
+ got := Default
55
+
56
+ if reflect .TypeOf (got ) != reflect .TypeOf (want ) {
57
+ t .Errorf ("wanted Default to be %T got %T" , want , got )
58
+ }
59
+ }
60
+
61
+ func TestNewAPI (t * testing.T ) {
62
+ _ = New ("/" )
63
+ }
Original file line number Diff line number Diff line change
1
+ //go:build !js
2
+ // +build !js
3
+
4
+ package osfs
5
+
6
+ import (
7
+ "reflect"
8
+ "testing"
9
+ )
10
+
11
+ func TestDefault (t * testing.T ) {
12
+ want := & ChrootOS {}
13
+ got := Default
14
+
15
+ if reflect .TypeOf (got ) != reflect .TypeOf (want ) {
16
+ t .Errorf ("wanted Default to be %T got %T" , want , got )
17
+ }
18
+ }
19
+
20
+ func TestNewAPI (t * testing.T ) {
21
+ _ = New ("/" )
22
+ _ = New ("/" , WithBoundOS ())
23
+ _ = New ("/" , WithChrootOS ())
24
+ }
You can’t perform that action at this time.
0 commit comments