-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
symlink_test_x.go
45 lines (37 loc) · 1.59 KB
/
symlink_test_x.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
43
44
45
//go:build windows || plan9 || netbsd || aix || illumos || solaris || js
package copy
import (
"os"
"testing"
. "github.com/otiai10/mint"
)
func TestOptions_OnSymlink(t *testing.T) {
opt := Options{OnSymlink: func(string) SymlinkAction { return Deep }}
err := Copy("test/data/case03", "test/data.copy/case03.deep", opt)
Expect(t, err).ToBe(nil)
info, err := os.Lstat("test/data.copy/case03.deep/case01")
Expect(t, err).ToBe(nil)
Expect(t, info.Mode()&os.ModeSymlink).ToBe(os.FileMode(0))
opt = Options{OnSymlink: func(string) SymlinkAction { return Shallow }}
err = Copy("test/data/case03", "test/data.copy/case03.shallow", opt)
Expect(t, err).ToBe(nil)
info, err = os.Lstat("test/data.copy/case03.shallow/case01")
Expect(t, err).ToBe(nil)
Expect(t, info.Mode()&os.ModeSymlink).Not().ToBe(os.FileMode(0))
opt = Options{OnSymlink: func(string) SymlinkAction { return Skip }}
err = Copy("test/data/case03", "test/data.copy/case03.skip", opt)
Expect(t, err).ToBe(nil)
_, err = os.Stat("test/data.copy/case03.skip/case01")
Expect(t, os.IsNotExist(err)).ToBe(true)
err = Copy("test/data/case03", "test/data.copy/case03.default")
Expect(t, err).ToBe(nil)
info, err = os.Lstat("test/data.copy/case03.default/case01")
Expect(t, err).ToBe(nil)
Expect(t, info.Mode()&os.ModeSymlink).Not().ToBe(os.FileMode(0))
opt = Options{OnSymlink: nil}
err = Copy("test/data/case03", "test/data.copy/case03.not-specified", opt)
Expect(t, err).ToBe(nil)
info, err = os.Lstat("test/data.copy/case03.not-specified/case01")
Expect(t, err).ToBe(nil)
Expect(t, info.Mode()&os.ModeSymlink).Not().ToBe(os.FileMode(0))
}