| 1 | package polyfill |
| 2 | |
| 3 | import ( |
| 4 | "path/filepath" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/go-git/go-billy/v6" |
| 8 | "github.com/go-git/go-billy/v6/internal/test" |
| 9 | "github.com/stretchr/testify/assert" |
| 10 | ) |
| 11 | |
| 12 | var helper = New(&test.BasicMock{}) |
| 13 | |
| 14 | func TestTempFile(t *testing.T) { |
| 15 | _, err := helper.TempFile("", "") |
| 16 | assert.ErrorIs(t, err, billy.ErrNotSupported) |
| 17 | } |
| 18 | |
| 19 | func TestReadDir(t *testing.T) { |
| 20 | _, err := helper.ReadDir("") |
| 21 | assert.ErrorIs(t, err, billy.ErrNotSupported) |
| 22 | } |
| 23 | |
| 24 | func TestMkdirAll(t *testing.T) { |
| 25 | err := helper.MkdirAll("", 0) |
| 26 | assert.ErrorIs(t, err, billy.ErrNotSupported) |
| 27 | } |
| 28 | |
| 29 | func TestSymlink(t *testing.T) { |
| 30 | err := helper.Symlink("", "") |
| 31 | assert.ErrorIs(t, err, billy.ErrNotSupported) |
| 32 | } |
| 33 | |
| 34 | func TestReadlink(t *testing.T) { |
| 35 | _, err := helper.Readlink("") |
| 36 | assert.ErrorIs(t, err, billy.ErrNotSupported) |
| 37 | } |
| 38 | |
| 39 | func TestLstat(t *testing.T) { |
| 40 | _, err := helper.Lstat("") |
| 41 | assert.ErrorIs(t, err, billy.ErrNotSupported) |
| 42 | } |
| 43 | |
| 44 | func TestChroot(t *testing.T) { |
| 45 | _, err := helper.Chroot("") |
| 46 | assert.ErrorIs(t, err, billy.ErrNotSupported) |
| 47 | } |
| 48 | |
| 49 | func TestChmod(t *testing.T) { |
| 50 | ch, ok := helper.(billy.Chmod) |
| 51 | assert.True(t, ok) |
| 52 | |
| 53 | err := ch.Chmod("", 0o444) |
| 54 | assert.ErrorIs(t, err, billy.ErrNotSupported) |
| 55 | } |
| 56 | |
| 57 | func TestRoot(t *testing.T) { |
| 58 | assert.Equal(t, string(filepath.Separator), helper.Root()) |
| 59 | } |
| 60 | |
| 61 | func TestCapabilities(t *testing.T) { |
| 62 | testCapabilities(t, new(test.BasicMock)) |
| 63 | testCapabilities(t, new(test.OnlyReadCapFs)) |
| 64 | testCapabilities(t, new(test.NoLockCapFs)) |
| 65 | } |
| 66 | |
| 67 | func testCapabilities(t *testing.T, basic billy.Basic) { |
| 68 | t.Helper() |
| 69 | baseCapabilities := billy.Capabilities(basic) |
| 70 | |
| 71 | fs := New(basic) |
| 72 | capabilities := billy.Capabilities(fs) |
| 73 | assert.Equal(t, baseCapabilities, capabilities) |
| 74 | } |