-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add subnet filtering to the CLI tool (#8)
- Loading branch information
Showing
3 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
cmd/cni-ipvlan-vpc-k8s-tool/cni-ipvlan-vpc-k8s-tool_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// TestFilterBuildNil checks the empty string input | ||
func TestFilterBuildNil(t *testing.T) { | ||
ret, err := filterBuild("") | ||
if ret != nil && err != nil { | ||
t.Errorf("Nil input wasn't nil") | ||
} | ||
} | ||
|
||
// TestFilterBuildSingle tests a single filter | ||
func TestFilterBuildSingle(t *testing.T) { | ||
ret, err := filterBuild("foo=bar") | ||
if err != nil { | ||
t.Errorf("Error returned") | ||
} | ||
if v, ok := ret["foo"]; !ok || v != "bar" { | ||
t.Errorf("Invalid return from filter") | ||
} | ||
} | ||
|
||
// TestFilterBuildMulti tests multiple filters | ||
func TestFilterBuildMulti(t *testing.T) { | ||
ret, err := filterBuild("foo=bar,err=frr") | ||
if err != nil { | ||
t.Errorf("Error returned") | ||
} | ||
if v, ok := ret["foo"]; !ok || v != "bar" { | ||
t.Errorf("Invalid return from filter - no foo") | ||
} | ||
if v, ok := ret["err"]; !ok || v != "frr" { | ||
t.Errorf("Invalid return from filter - no frr") | ||
} | ||
|
||
} |