Skip to content

Commit

Permalink
Merge pull request #8955 from hs0210/work
Browse files Browse the repository at this point in the history
Add unit test for func JoinSuffixes
  • Loading branch information
k8s-ci-robot committed Apr 22, 2020
2 parents a57a404 + d3d4afd commit bb48a8c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/model/firewall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,34 @@ func Test_SharedGroups(t *testing.T) {
}
}
}

func TestJoinSuffixes(t *testing.T) {
grid := []struct {
src SecurityGroupInfo
dest SecurityGroupInfo
expected string
}{
{
src: SecurityGroupInfo{Suffix: ""},
dest: SecurityGroupInfo{Suffix: ""},
expected: "",
},
{
src: SecurityGroupInfo{Suffix: "srcSuffix"},
dest: SecurityGroupInfo{Suffix: ""},
expected: "srcSuffix-default",
},
{
src: SecurityGroupInfo{Suffix: ""},
dest: SecurityGroupInfo{Suffix: "destSuffix"},
expected: "-defaultdestSuffix",
},
}

for _, g := range grid {
actual := JoinSuffixes(g.src, g.dest)
if actual != g.expected {
t.Errorf("unexpected result. expected %q, got %q", g.expected, actual)
}
}
}

0 comments on commit bb48a8c

Please sign in to comment.