Skip to content

Commit bab4079

Browse files
committed
Re-introduce osfs.Default
The Default var was incorrectly removed as part of go-git#31. This PR revert that change and adds tests to avoid future regression. Signed-off-by: Paulo Gomes <[email protected]>
1 parent 1d4d3d3 commit bab4079

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

osfs/os.go

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const (
1818
defaultCreateMode = 0o666
1919
)
2020

21+
// Default Filesystem representing the root of the os filesystem.
22+
var Default = &ChrootOS{}
23+
2124
// New returns a new OS filesystem.
2225
func New(baseDir string, opts ...Option) billy.Filesystem {
2326
o := &options{}

osfs/os_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package osfs
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
func TestDefault(t *testing.T) {
9+
if reflect.TypeOf(Default) != reflect.TypeOf(&ChrootOS{}) {
10+
t.Errorf("wanted Default to be %T got %T", ChrootOS{}, Default)
11+
}
12+
}
13+
14+
func TestNewAPI(t *testing.T) {
15+
_ = New("/")
16+
_ = New("/", WithBoundOS())
17+
_ = New("/", WithChrootOS())
18+
}

0 commit comments

Comments
 (0)