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