37 lines
714 B
Go
37 lines
714 B
Go
package fsys
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestStorageLocalErrors(t *testing.T) {
|
|
|
|
err := os.WriteFile("./test/local/non_folder", []byte("hi"), 0640)
|
|
assert.NoError(t, err)
|
|
|
|
t.Log("== InvalidPathErr ==")
|
|
_, err = New(Config{
|
|
Type: "local",
|
|
Path: "./test/local/non_folder",
|
|
})
|
|
assert.Error(t, err)
|
|
|
|
stor, err := New(Config{
|
|
Type: "local",
|
|
Path: "./test/local",
|
|
})
|
|
assert.NoError(t, err)
|
|
|
|
t.Log("== FileNotExistErr ==")
|
|
_, err = stor.Stat("nonexistent")
|
|
assert.Error(t, err)
|
|
assert.Equal(t, ErrFileNotFound, err)
|
|
|
|
t.Log("== FolderNotExistErr ==")
|
|
_, err = stor.ReadDir("nonexistent")
|
|
assert.Error(t, err)
|
|
assert.Equal(t, ErrFolderNotFound, err)
|
|
|
|
}
|