File tree Expand file tree Collapse file tree 4 files changed +54
-9
lines changed Expand file tree Collapse file tree 4 files changed +54
-9
lines changed Original file line number Diff line number Diff line change
1
+ // +build js
2
+
1
3
package osfs
2
4
3
5
import (
@@ -9,15 +11,7 @@ import (
9
11
// globalMemFs is the global memory fs
10
12
var globalMemFs = memfs .New ()
11
13
12
- const (
13
- defaultDirectoryMode = 0755
14
- defaultCreateMode = 0666
15
- )
16
-
17
- // OS is a filesystem shim for js.
18
- type OS struct {}
19
-
20
14
// New returns a new OS filesystem.
21
15
func New (baseDir string ) billy.Filesystem {
22
- return chroot .New (globalMemFs , baseDir )
16
+ return chroot .New (globalMemFs , globalMemFs . Join ( "/" , baseDir ) )
23
17
}
Original file line number Diff line number Diff line change
1
+ // +build js
2
+
3
+ package osfs
4
+
5
+ import (
6
+ "fmt"
7
+ "os"
8
+ "path/filepath"
9
+ "testing"
10
+
11
+ "github.com/go-git/go-billy/v5"
12
+ "github.com/go-git/go-billy/v5/test"
13
+
14
+ . "gopkg.in/check.v1"
15
+ )
16
+
17
+ func Test (t * testing.T ) { TestingT (t ) }
18
+
19
+ type OSSuite struct {
20
+ test.FilesystemSuite
21
+ path string
22
+ tempCounter int
23
+ }
24
+
25
+ var _ = Suite (& OSSuite {})
26
+
27
+ func (s * OSSuite ) SetUpTest (c * C ) {
28
+ s .tempCounter ++
29
+ s .path = fmt .Sprintf ("test_%d" , s .tempCounter )
30
+ s .FilesystemSuite = test .NewFilesystemSuite (New (s .path ))
31
+ }
32
+
33
+ func (s * OSSuite ) TestOpenDoesNotCreateDir (c * C ) {
34
+ _ , err := s .FS .Open ("dir/non-existent" )
35
+ c .Assert (err , NotNil )
36
+
37
+ _ , err = s .FS .Stat (filepath .Join (s .path , "dir" ))
38
+ c .Assert (os .IsNotExist (err ), Equals , true )
39
+ }
40
+
41
+ func (s * OSSuite ) TestCapabilities (c * C ) {
42
+ _ , ok := s .FS .(billy.Capable )
43
+ c .Assert (ok , Equals , true )
44
+
45
+ caps := billy .Capabilities (s .FS )
46
+ c .Assert (caps , Equals , billy .DefaultCapabilities &^billy .LockCapability )
47
+ }
Original file line number Diff line number Diff line change
1
+ // +build plan9
2
+
1
3
package osfs
2
4
3
5
import (
Original file line number Diff line number Diff line change
1
+ // +build !js
2
+
1
3
package osfs
2
4
3
5
import (
You can’t perform that action at this time.
0 commit comments