-
Notifications
You must be signed in to change notification settings - Fork 1
/
patherror_test.go
41 lines (31 loc) · 1.05 KB
/
patherror_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package aferocopy
import (
"os"
"path/filepath"
"runtime"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCopy_PathError(t *testing.T) {
t.Run("too long name is given", func(t *testing.T) {
dest := strings.Repeat("foobar", 64)
err := Copy("resources/fixtures/data/case00", filepath.Join("resources/test/data/case00", dest))
require.Error(t, err)
assert.IsType(t, &os.PathError{}, err)
})
t.Run("try to create not permitted location", func(t *testing.T) {
if runtime.GOOS == "windows" || runtime.GOOS == "freebsd" || os.Getenv("TESTCASE") != "" {
t.Skipf("FIXME: error IS nil here in Windows and FreeBSD")
}
err := Copy("resources/fixtures/data/case00", "/case00")
require.Error(t, err)
assert.IsType(t, &os.PathError{}, err)
})
t.Run("try to create a directory on existing file name", func(t *testing.T) {
err := Copy("resources/fixtures/data/case02", "resources/test/data.copy/case00/README.md")
require.Error(t, err)
assert.IsType(t, &os.PathError{}, err)
})
}