Skip to content

Commit

Permalink
Re-introduce osfs.Default
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pjbgf committed Aug 29, 2023
1 parent 1d4d3d3 commit bab4079
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions osfs/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const (
defaultCreateMode = 0o666
)

// Default Filesystem representing the root of the os filesystem.
var Default = &ChrootOS{}

// New returns a new OS filesystem.
func New(baseDir string, opts ...Option) billy.Filesystem {
o := &options{}
Expand Down
18 changes: 18 additions & 0 deletions osfs/os_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package osfs

import (
"reflect"
"testing"
)

func TestDefault(t *testing.T) {
if reflect.TypeOf(Default) != reflect.TypeOf(&ChrootOS{}) {

Check failure on line 9 in osfs/os_test.go

View workflow job for this annotation

GitHub Actions / test (1.20.x)

undefined: ChrootOS
t.Errorf("wanted Default to be %T got %T", ChrootOS{}, Default)

Check failure on line 10 in osfs/os_test.go

View workflow job for this annotation

GitHub Actions / test (1.20.x)

undefined: ChrootOS
}
}

func TestNewAPI(t *testing.T) {
_ = New("/")
_ = New("/", WithBoundOS())

Check failure on line 16 in osfs/os_test.go

View workflow job for this annotation

GitHub Actions / test (1.20.x)

undefined: WithBoundOS
_ = New("/", WithChrootOS())

Check failure on line 17 in osfs/os_test.go

View workflow job for this annotation

GitHub Actions / test (1.20.x)

undefined: WithChrootOS
}

0 comments on commit bab4079

Please sign in to comment.