fsys/local_errors_test.go

38 lines
714 B
Go
Raw Normal View History

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 ==")
2024-11-21 18:12:05 +01:00
_, err = stor.Stat("nonexistent")
assert.Error(t, err)
assert.Equal(t, ErrFileNotFound, err)
t.Log("== FolderNotExistErr ==")
2024-11-21 18:12:05 +01:00
_, err = stor.ReadDir("nonexistent")
assert.Error(t, err)
assert.Equal(t, ErrFolderNotFound, err)
}