| 1 |
|
| 2 |
|
| 3 |
package osfs |
| 4 |
|
| 5 |
import ( |
| 6 |
"path/filepath" |
| 7 |
"reflect" |
| 8 |
"testing" |
| 9 |
|
| 10 |
"github.com/go-git/go-billy/v6" |
| 11 |
"github.com/stretchr/testify/assert" |
| 12 |
) |
| 13 |
|
| 14 |
func TestOpenDoesNotCreateDir(t *testing.T) { |
| 15 |
fs := New("/some/path") |
| 16 |
_, err := fs.Open("dir/non-existent") |
| 17 |
assert.Error(t, err) |
| 18 |
|
| 19 |
_, err = fs.Stat(filepath.Join("/some/path", "dir")) |
| 20 |
assert.Error(t, err) |
| 21 |
} |
| 22 |
|
| 23 |
func TestCapabilities(t *testing.T) { |
| 24 |
fs := New("/some/path") |
| 25 |
_, ok := fs.(billy.Capable) |
| 26 |
assert.True(t, ok) |
| 27 |
|
| 28 |
caps := billy.Capabilities(fs) |
| 29 |
assert.Equal(t, billy.DefaultCapabilities, caps) |
| 30 |
} |
| 31 |
|
| 32 |
func TestDefault(t *testing.T) { |
| 33 |
want := Default |
| 34 |
got := Default |
| 35 |
|
| 36 |
if reflect.TypeOf(got) != reflect.TypeOf(want) { |
| 37 |
t.Errorf("wanted Default to be %T got %T", want, got) |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
func TestNewAPI(t *testing.T) { |
| 42 |
_ = New("/") |
| 43 |
} |