added async connect API, new structure of examples
[govpp.git] / core / core_test.go
index d3c2e2c..3184ef5 100644 (file)
@@ -145,6 +145,7 @@ func TestNotifications(t *testing.T) {
 }
 
 func TestNilConnection(t *testing.T) {
+       RegisterTestingT(t)
        var conn *Connection
 
        ch, err := conn.NewAPIChannel()
@@ -168,6 +169,21 @@ func TestDoubleConnection(t *testing.T) {
        Expect(conn).Should(BeNil())
 }
 
+func TestAsyncConnection(t *testing.T) {
+       ctx := setupTest(t)
+       defer ctx.teardownTest()
+
+       ctx.conn.Disconnect()
+       conn, ch, err := AsyncConnect(ctx.mockVpp)
+       ctx.conn = conn
+
+       Expect(err).ShouldNot(HaveOccurred())
+       Expect(conn).ShouldNot(BeNil())
+
+       ev := <-ch
+       Expect(ev.State).Should(BeEquivalentTo(Connected))
+}
+
 func TestFullBuffer(t *testing.T) {
        ctx := setupTest(t)
        defer ctx.teardownTest()