Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if list bridge output is empty #54

Merged
merged 3 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ovs/vswitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func (v *VSwitchService) ListPorts(bridge string) ([]string, error) {
return nil, err
}

if string(output) == "" {
return nil, nil
}
ports := strings.Split(strings.TrimSpace(string(output)), "\n")
return ports, err
}
Expand All @@ -88,6 +91,9 @@ func (v *VSwitchService) ListBridges() ([]string, error) {
return nil, err
}

if string(output) == "" {
return nil, nil
}
bridges := strings.Split(strings.TrimSpace(string(output)), "\n")
return bridges, err
}
Expand Down
17 changes: 17 additions & 0 deletions ovs/vswitch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ func TestClientVSwitchListPorts(t *testing.T) {
err error
c *Client
}{
{
name: "test br0 bonded with no interface",
input: "br0",
want: nil,
err: nil,
c: testClient(nil, func(cmd string, args ...string) ([]byte, error) {
return []byte(""), nil
}),
},
{
name: "test br0 bonded",
input: "br0",
Expand Down Expand Up @@ -260,6 +269,14 @@ func TestClientVSwitchListBridges(t *testing.T) {
err error
c *Client
}{
{
name: "test no bridge",
want: nil,
err: nil,
c: testClient(nil, func(cmd string, args ...string) ([]byte, error) {
return []byte(""), nil
}),
},
{
name: "test single bridge",
want: []string{"br0"},
Expand Down