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"
)
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()
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()