-
Notifications
You must be signed in to change notification settings - Fork 30
/
times_windows_test.go
54 lines (46 loc) · 1.05 KB
/
times_windows_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
43
44
45
46
47
48
49
50
51
52
53
54
package times
import (
"errors"
"os"
"syscall"
"testing"
"time"
)
func TestStatFileProcErr(t *testing.T) {
fileTest(t, func(f *os.File) {
findProcErr = errors.New("fake error")
defer func() { findProcErr = nil }()
_, err := StatFile(f)
if err == nil {
t.Error("got nil err, but err was expected!")
}
})
}
func TestStatBadNameErr(t *testing.T) {
_, err := platformSpecficStat(string([]byte{0}))
if err != syscall.EINVAL {
t.Error(err)
}
}
func TestStatProcErrFallback(t *testing.T) {
fileAndDirTest(t, func(name string) {
findProcErr = errors.New("fake error")
defer func() { findProcErr = nil }()
ts, err := Stat(name)
if err != nil {
t.Error(err.Error())
}
timespecTest(ts, newInterval(time.Now(), time.Second), t)
})
}
func TestLstatProcErrFallback(t *testing.T) {
fileAndDirTest(t, func(name string) {
findProcErr = errors.New("fake error")
defer func() { findProcErr = nil }()
ts, err := Lstat(name)
if err != nil {
t.Error(err.Error())
}
timespecTest(ts, newInterval(time.Now(), time.Second), t)
})
}