-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathrequest_handler_test.go
More file actions
41 lines (31 loc) · 1.24 KB
/
Copy pathrequest_handler_test.go
File metadata and controls
41 lines (31 loc) · 1.24 KB
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
package core
import (
"testing"
. "github.com/onsi/gomega"
"go.fd.io/govpp/api"
interfaces "go.fd.io/govpp/binapi/interface"
)
func TestNotificationMessageAfterUnsubscribe(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
notifMsg := &interfaces.SwInterfaceEvent{}
msgID, err := ctx.conn.GetMessageID(notifMsg)
Expect(err).ShouldNot(HaveOccurred())
// Before subscribing, isNotificationMessage should return false
isNotif := ctx.conn.isNotificationMessage(msgID)
Expect(isNotif).Should(BeFalse())
// Subscribe to the notification
notifChan := make(chan api.Message, 10)
sub, err := ctx.ch.SubscribeNotification(notifChan, notifMsg)
Expect(err).ShouldNot(HaveOccurred())
Expect(sub).ShouldNot(BeNil())
// After subscribing, isNotificationMessage should return true
isNotif = ctx.conn.isNotificationMessage(msgID)
Expect(isNotif).Should(BeTrue())
// Unsubscribe from the notification
err = sub.Unsubscribe()
Expect(err).ShouldNot(HaveOccurred())
// After unsubscribing the last (and only) subscription, isNotificationMessage should return false
isNotif = ctx.conn.isNotificationMessage(msgID)
Expect(isNotif).Should(BeFalse(), "isNotificationMessage should return false after unsubscribing from the last subscription")
}