Add unit test for func RenderInstanceGroupSubnets in instancegroup.go

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
This commit is contained in:
Guangwen Feng 2020-01-02 15:14:48 +08:00
parent a65422dd46
commit d80aed0c9d
1 changed files with 33 additions and 0 deletions

View File

@ -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
}
}
}