diff --git a/osfs/os.go b/osfs/os.go index 32ea0e5..cb7489a 100644 --- a/osfs/os.go +++ b/osfs/os.go @@ -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{} diff --git a/osfs/os_js_test.go b/osfs/os_js_test.go index a62d103..7d8f8ca 100644 --- a/osfs/os_js_test.go +++ b/osfs/os_js_test.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "path/filepath" + "reflect" "testing" "github.com/go-git/go-billy/v5" @@ -46,3 +47,16 @@ func (s *OSSuite) TestCapabilities(c *C) { caps := billy.Capabilities(s.FS) c.Assert(caps, Equals, billy.DefaultCapabilities&^billy.LockCapability) } + +func TestDefault(t *testing.T) { + want := &ChrootHelper{} // chroot + memfs + got := Default + + if reflect.TypeOf(got) != reflect.TypeOf(want) { + t.Errorf("wanted Default to be %T got %T", want, got) + } +} + +func TestNewAPI(t *testing.T) { + _ = New("/") +} diff --git a/osfs/os_test.go b/osfs/os_test.go new file mode 100644 index 0000000..81ecf62 --- /dev/null +++ b/osfs/os_test.go @@ -0,0 +1,24 @@ +//go:build !js +// +build !js + +package osfs + +import ( + "reflect" + "testing" +) + +func TestDefault(t *testing.T) { + want := &ChrootOS{} + got := Default + + if reflect.TypeOf(got) != reflect.TypeOf(want) { + t.Errorf("wanted Default to be %T got %T", want, got) + } +} + +func TestNewAPI(t *testing.T) { + _ = New("/") + _ = New("/", WithBoundOS()) + _ = New("/", WithChrootOS()) +}