-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption_test.go
79 lines (63 loc) · 2.33 KB
/
option_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package gta
import (
"testing"
"time"
"github.com/smartystreets/goconvey/convey"
"gorm.io/gorm"
)
func Test_newOptions(t *testing.T) {
defaultDB := &gorm.DB{}
defaultTable := "tasks"
convey.Convey("Test_newOptions", t, func() {
convey.Convey("normal process", func() {
_, err := newOptions(defaultDB, defaultTable)
convey.So(err, convey.ShouldBeNil)
})
convey.Convey("nil db", func() {
_, err := newOptions(defaultDB, defaultTable, withDB(nil))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("empty table name", func() {
_, err := newOptions(defaultDB, defaultTable, withTable(""))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("nil logger factory", func() {
_, err := newOptions(defaultDB, defaultTable, WithLoggerFactory(nil))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("nil ctxMashaler", func() {
_, err := newOptions(defaultDB, defaultTable, WithCtxMarshaler(nil))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("invalid running timeout", func() {
_, err := newOptions(defaultDB, defaultTable, WithRunningTimeout(time.Hour*365))
convey.So(err, convey.ShouldNotBeNil)
_, err = newOptions(defaultDB, defaultTable, WithRunningTimeout(-time.Hour*365))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("invalid initialized timeout", func() {
_, err := newOptions(defaultDB, defaultTable, WithInitializedTimeout(time.Hour*365))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("invalid scan interval", func() {
_, err := newOptions(defaultDB, defaultTable, WithScanInterval(time.Hour*365))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("invalid instant scan interval", func() {
_, err := newOptions(defaultDB, defaultTable, WithInstantScanInterval(time.Hour*365))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("invalid wait timeout", func() {
_, err := newOptions(defaultDB, defaultTable, WithWaitTimeout(-time.Hour*365))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("invalid pool size", func() {
_, err := newOptions(defaultDB, defaultTable, WithPoolSize(-1))
convey.So(err, convey.ShouldNotBeNil)
})
convey.Convey("nil task register", func() {
_, err := newOptions(defaultDB, defaultTable, withTaskRegister(nil))
convey.So(err, convey.ShouldNotBeNil)
})
})
}