-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathapi_test.go
59 lines (50 loc) · 1.41 KB
/
api_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
package tracing
import (
gomock "github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Api", func() {
var (
mockCtrl *gomock.Controller
domain *MockNamedHookable
)
BeforeEach(func() {
mockCtrl = gomock.NewController(GinkgoT())
domain = NewMockNamedHookable(mockCtrl)
domain.EXPECT().NumHooks().Return(1).AnyTimes()
domain.EXPECT().InvokeHook(gomock.Any()).AnyTimes()
})
AfterEach(func() {
mockCtrl.Finish()
})
It("should panic if ID is not given", func() {
domain.EXPECT().Name().Return("domain").AnyTimes()
Expect(func() {
StartTask("", "123", domain, "kind", "what", nil)
}).Should(Panic())
})
It("should be panic if domain is nil.", func() {
Expect(func() {
StartTask("id", "123", nil, "kind", "what", nil)
}).Should(Panic())
})
It("should be panic if domain's name is empty.", func() {
domain.EXPECT().Name().Return("").AnyTimes()
Expect(func() {
StartTask("id", "123", domain, "kind", "what", nil)
}).Should(Panic())
})
It("should be panic if kind is empty.", func() {
domain.EXPECT().Name().Return("domain").AnyTimes()
Expect(func() {
StartTask("id", "123", domain, "", "what", nil)
}).Should(Panic())
})
It("should be panic if what is empty.", func() {
domain.EXPECT().Name().Return("domain").AnyTimes()
Expect(func() {
StartTask("id", "123", domain, "kind", "", nil)
}).Should(Panic())
})
})