forked from otiai10/copy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patherror_go1.16_test.go
42 lines (34 loc) · 1.02 KB
/
patherror_go1.16_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
42
//go:build go1.16
// +build go1.16
package copy
import (
"os"
"path/filepath"
"runtime"
"testing"
. "github.com/otiai10/mint"
)
func TestCopy_PathError(t *testing.T) {
When(t, "too long name is given", func(t *testing.T) {
dest := "foobar"
for i := 0; i < 8; i++ {
dest = dest + dest
}
err := Copy("test/data/case00", filepath.Join("test/data/case00", dest))
Expect(t, err).Not().ToBe(nil)
Expect(t, err).TypeOf("*fs.PathError")
})
When(t, "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("test/data/case00", "/case00")
Expect(t, err).Not().ToBe(nil)
Expect(t, err).TypeOf("*fs.PathError")
})
When(t, "try to create a directory on existing file name", func(t *testing.T) {
err := Copy("test/data/case02", "test/data.copy/case00/README.md")
Expect(t, err).Not().ToBe(nil)
Expect(t, err).TypeOf("*fs.PathError")
})
}