File: times_windows_test.go

package info (click to toggle)
golang-github-djherbis-times 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: sh: 10; makefile: 3
file content (54 lines) | stat: -rw-r--r-- 1,073 bytes parent folder | download | duplicates (2)
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)
	})
}