Skip to content

Commit

Permalink
Add unit test for func RenderInstanceGroupSubnets in instancegroup.go
Browse files Browse the repository at this point in the history
Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
  • Loading branch information
Guangwen Feng committed Jan 13, 2020
1 parent a65422d commit d80aed0
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/formatter/instancegroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,36 @@ func TestRenderInstanceGroupZones(t *testing.T) {
}
}
}

func TestRenderInstanceGroupSubnets(t *testing.T) {
cluster := &kops.Cluster{}
grid := []struct {
ig *kops.InstanceGroup
expected string
}{
{
ig: &kops.InstanceGroup{
Spec: kops.InstanceGroupSpec{
Subnets: []string{"subnet"},
},
},
expected: "subnet",
},
{
ig: &kops.InstanceGroup{
Spec: kops.InstanceGroupSpec{
Subnets: []string{"subnet1", "subnet2"},
},
},
expected: "subnet1,subnet2",
},
}
for _, g := range grid {
f := RenderInstanceGroupSubnets(cluster)
actual := f(g.ig)
if actual != g.expected {
t.Errorf("unexpected output: %q vs %q", g.expected, actual)
continue
}
}
}

0 comments on commit d80aed0

Please sign in to comment.