-
Notifications
You must be signed in to change notification settings - Fork 0
/
cap_test.go
39 lines (32 loc) · 918 Bytes
/
cap_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
package timecat
import (
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
)
func TestCap(t *testing.T) {
Convey("cap usage", t, func() {
freeze, _ := time.Parse("2006-01-02T15:04:05Z07:00", "2021-10-24T11:21:23-05:00")
oldNow := mockNow(func() time.Time { return freeze })
Reset(func() { now = oldNow })
Convey("when not given a directory", func() {
var testDirContents = []string{}
oldReadDir := mockReadDir(testDirContents)
Reset(func() { readDir = oldReadDir })
Convey("Should just have the cap heading", func() {
assertCapOnly()
})
})
Convey("When given a non empty directory but no dated files", func() {
var testDirContents = []string{
"testfile",
"testfile2",
}
oldReadDir := mockReadDir(testDirContents)
Reset(func() { readDir = oldReadDir })
Convey("Should just have the cap heading", func() {
assertCapOnly()
})
})
})
}