This repository has been archived by the owner on Feb 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_test.go
67 lines (58 loc) · 1.76 KB
/
basic_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
package lifecycle
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("basicEvent", func() {
Describe("Component", func() {
It("Should return the right component", func() {
e := &basicEvent{Comp: "test"}
Expect(e.Component()).To(Equal("test"))
})
})
Describe("SetComponent", func() {
It("Should set the component", func() {
e := &basicEvent{}
e.SetComponent("component")
Expect(e.Comp).To(Equal("component"))
})
})
Describe("SetIdentity", func() {
It("Should set the identity", func() {
e := &basicEvent{}
e.SetIdentity("node.example")
Expect(e.Ident).To(Equal("node.example"))
})
})
Describe("Target", func() {
It("Should detect incomplete events", func() {
e := &basicEvent{etype: "basic"}
_, err := e.Target()
Expect(err).To(MatchError("event is not complete, component has not been set"))
})
It("Should return the right target", func() {
e := &basicEvent{etype: "basic", Comp: "ginkgo"}
t, err := e.Target()
Expect(err).ToNot(HaveOccurred())
Expect(t).To(Equal("choria.lifecycle.event.basic.ginkgo"))
})
})
Describe("String", func() {
It("Should return the right string", func() {
e := &basicEvent{etype: "basic", Comp: "ginkgo", Ident: "node.example"}
Expect(e.String()).To(Equal("[basic] node.example: ginkgo"))
})
})
Describe("Type", func() {
It("Should return the right Type", func() {
e := &basicEvent{etype: "basic", dtype: Shutdown, Comp: "ginkg", Ident: "node.example"}
Expect(e.Type()).To(Equal(Shutdown))
})
})
Describe("TypeString", func() {
It("Should return the right string", func() {
e := &basicEvent{etype: "shutdown", dtype: Shutdown, Comp: "ginkg", Ident: "node.example"}
Expect(e.TypeString()).To(Equal("shutdown"))
})
})
})