added async connect API, new structure of examples
[govpp.git] / core / core_test.go
index c95ef04..3184ef5 100644 (file)
@@ -17,10 +17,10 @@ package core
 import (
        "testing"
 
-       "gerrit.fd.io/r/govpp/adapter/mock"
-       "gerrit.fd.io/r/govpp/api"
-       "gerrit.fd.io/r/govpp/core/bin_api/vpe"
-       "gerrit.fd.io/r/govpp/examples/bin_api/interfaces"
+       "git.fd.io/govpp.git/adapter/mock"
+       "git.fd.io/govpp.git/api"
+       "git.fd.io/govpp.git/core/bin_api/vpe"
+       "git.fd.io/govpp.git/examples/bin_api/interfaces"
 
        . "github.com/onsi/gomega"
 )
@@ -144,6 +144,21 @@ func TestNotifications(t *testing.T) {
        Expect(err).ShouldNot(HaveOccurred())
 }
 
+func TestNilConnection(t *testing.T) {
+       RegisterTestingT(t)
+       var conn *Connection
+
+       ch, err := conn.NewAPIChannel()
+       Expect(ch).Should(BeNil())
+       Expect(err).Should(HaveOccurred())
+       Expect(err.Error()).To(ContainSubstring("nil"))
+
+       ch, err = conn.NewAPIChannelBuffered(1, 1)
+       Expect(ch).Should(BeNil())
+       Expect(err).Should(HaveOccurred())
+       Expect(err.Error()).To(ContainSubstring("nil"))
+}
+
 func TestDoubleConnection(t *testing.T) {
        ctx := setupTest(t)
        defer ctx.teardownTest()
@@ -154,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()