-
Notifications
You must be signed in to change notification settings - Fork 0
/
listener_test.go
48 lines (39 loc) · 1.42 KB
/
listener_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
package apidGatewayTrace
import (
"github.com/apigee-labs/transicator/common"
. "github.com/onsi/ginkgo"
)
var _ = Describe("Listener", func() {
Context("ApigeeSync snapshot event", func() {
It("listener should process a snapshot", func() {
apiManager := new(mockApiManager)
apiManager.On("InitAPI").Return()
dbManager := new(mockDbManager)
dbManager.On("setDbVersion", "testSnapshotId").Return()
handler := apigeeSyncHandler{
dbMan: dbManager,
apiMan: apiManager,
closed: false,
}
handler.Handle(&common.Snapshot{SnapshotInfo: "testSnapshotId"})
apiManager.AssertNumberOfCalls(GinkgoT(), "InitAPI", 1)
dbManager.AssertNumberOfCalls(GinkgoT(), "setDbVersion", 1)
})
It("listener should process a changelist", func() {
apiManager := new(mockApiManager)
apiManager.On("notifyChange", true)
handler := apigeeSyncHandler{
dbMan: nil,
apiMan: apiManager,
closed: false,
}
// test changelist with all operations. Only Insert and Delete for trace table should trigger notifications
handler.Handle(&common.ChangeList{Changes: []common.Change{
{Table: TRACESIGNAL_PG_TABLENAME, Operation: common.Insert},
{Table: TRACESIGNAL_PG_TABLENAME, Operation: common.Delete},
{Table: "not.trace.metadata", Operation: common.Insert},
{Table: TRACESIGNAL_PG_TABLENAME, Operation: common.Update}}})
apiManager.AssertNumberOfCalls(GinkgoT(), "notifyChange", 2)
})
})
})