From 4689d20e3d34af4c706e2273e2bbac8b5c558395 Mon Sep 17 00:00:00 2001 From: Zhenfang Wei Date: Tue, 29 Mar 2016 06:51:52 +0000 Subject: [PATCH] Added a few test code --- ovsbridge_test.go | 9 +++++++++ ovsclient.go | 5 +++++ ovsclient_test.go | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/ovsbridge_test.go b/ovsbridge_test.go index 3a6f594..ebe9a18 100644 --- a/ovsbridge_test.go +++ b/ovsbridge_test.go @@ -1 +1,10 @@ package goovs + +import ( + "testing" +) + +func TestBridgeExists(t *testing.T) { + brname := "nonexistentbr" + +} \ No newline at end of file diff --git a/ovsclient.go b/ovsclient.go index 4e5e932..f85c7b5 100644 --- a/ovsclient.go +++ b/ovsclient.go @@ -56,6 +56,7 @@ type OvsClient interface { FindAllPortsOnBridge(brname string) ([]string, error) PortExistsOnBridge(portname, brname string) (bool, error) RemoveInterfaceFromPort(portname, interfaceUUID string) error + Disconnect() } type ovsClient struct { @@ -127,6 +128,10 @@ func GetOVSClient(contype, endpoint string) (OvsClient, error) { return client, nil } +func (client *ovsClient) Disconnect() { + client.dbClient.Disconnect() +} + func (client *ovsClient) transact(operations []libovsdb.Operation, action string) error { reply, _ := client.dbClient.Transact(defaultOvsDB, operations...) diff --git a/ovsclient_test.go b/ovsclient_test.go index 3a6f594..0131240 100644 --- a/ovsclient_test.go +++ b/ovsclient_test.go @@ -1 +1,14 @@ package goovs + +import ( + "testing" +) + +func preparingEnv() OvsClient{ + client, _ := GetOVSClient("tcp", "ovs:6640") + return client +} + +func tearDown(client OvsClient) { + client.Disconnect() +} \ No newline at end of file