-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
preserve_ltimes_test.go
34 lines (28 loc) · 1 KB
/
preserve_ltimes_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
//go:build !windows && !plan9 && !js
package copy
import (
"os"
"testing"
. "github.com/otiai10/mint"
"golang.org/x/sys/unix"
)
func TestOptions_PreserveLTimes(t *testing.T) {
err := Copy("test/data/case15", "test/data.copy/case15")
Expect(t, err).ToBe(nil)
opt := Options{PreserveTimes: true}
err = Copy("test/data/case15", "test/data.copy/case15-preserveltimes", opt)
Expect(t, err).ToBe(nil)
orig, err := os.Lstat("test/data/case15/symlink")
Expect(t, err).ToBe(nil)
plain, err := os.Lstat("test/data.copy/case15/symlink")
Expect(t, err).ToBe(nil)
preserved, err := os.Lstat("test/data.copy/case15-preserveltimes/symlink")
Expect(t, err).ToBe(nil)
Expect(t, plain.ModTime().Unix()).Not().ToBe(orig.ModTime().Unix())
Expect(t, preserved.ModTime().Unix()).ToBe(orig.ModTime().Unix())
}
func TestOptions_PreserveLTimesErrorReturn(t *testing.T) {
err := preserveLtimes("doesnotexist_original.txt", "doesnotexist_copy.txt")
Expect(t, err).ToBe(unix.ENOENT)
Expect(t, os.IsNotExist(err)).ToBe(true)
}