Skip to content

Commit afe9381

Browse files
author
Falcon Taylor-Carter
committed
Refactor zone type test
1 parent b8cee43 commit afe9381

File tree

1 file changed

+14
-58
lines changed

1 file changed

+14
-58
lines changed

provider/zone_type_filter_test.go

+14-58
Original file line numberDiff line numberDiff line change
@@ -25,83 +25,39 @@ import (
2525
"github.com/stretchr/testify/assert"
2626
)
2727

28-
func TestZoneTypeFilterMatchAWS(t *testing.T) {
29-
publicZone := &route53.HostedZone{Config: &route53.HostedZoneConfig{PrivateZone: aws.Bool(false)}}
30-
privateZone := &route53.HostedZone{Config: &route53.HostedZoneConfig{PrivateZone: aws.Bool(true)}}
31-
32-
for _, tc := range []struct {
33-
zoneTypeFilter string
34-
zone *route53.HostedZone
35-
matches bool
36-
}{
37-
{
38-
"", publicZone, true,
39-
},
40-
{
41-
"", privateZone, true,
42-
},
43-
{
44-
"public", publicZone, true,
45-
},
46-
{
47-
"public", privateZone, false,
48-
},
49-
{
50-
"private", publicZone, false,
51-
},
52-
{
53-
"private", privateZone, true,
54-
},
55-
{
56-
"unknown", publicZone, false,
57-
},
58-
{
59-
"", &route53.HostedZone{}, true,
60-
},
61-
{
62-
"public", &route53.HostedZone{}, true,
63-
},
64-
{
65-
"private", &route53.HostedZone{}, false,
66-
},
67-
} {
68-
zoneTypeFilter := NewZoneTypeFilter(tc.zoneTypeFilter)
69-
assert.Equal(t, tc.matches, zoneTypeFilter.Match(tc.zone))
70-
}
71-
}
72-
7328
func TestZoneTypeFilterMatch(t *testing.T) {
74-
publicZone := "public"
75-
privateZone := "private"
29+
publicZoneStr := "public"
30+
privateZoneStr := "private"
31+
publicZoneAWS := &route53.HostedZone{Config: &route53.HostedZoneConfig{PrivateZone: aws.Bool(false)}}
32+
privateZoneAWS := &route53.HostedZone{Config: &route53.HostedZoneConfig{PrivateZone: aws.Bool(true)}}
7633

7734
for _, tc := range []struct {
7835
zoneTypeFilter string
79-
zone string
8036
matches bool
37+
zones []interface{}
8138
}{
8239
{
83-
"", publicZone, true,
84-
},
85-
{
86-
"", privateZone, true,
40+
"", true, []interface{}{ publicZoneStr, privateZoneStr, &route53.HostedZone{} },
8741
},
8842
{
89-
"public", publicZone, true,
43+
"public", true, []interface{}{ publicZoneStr, publicZoneAWS, &route53.HostedZone{} },
9044
},
9145
{
92-
"public", privateZone, false,
46+
"public", false, []interface{}{ privateZoneStr, privateZoneAWS },
9347
},
9448
{
95-
"private", publicZone, false,
49+
"private", true, []interface{}{ privateZoneStr, privateZoneAWS },
9650
},
9751
{
98-
"private", privateZone, true,
52+
"private", false, []interface{}{ publicZoneStr, publicZoneAWS, &route53.HostedZone{} },
9953
},
10054
{
101-
"unknown", publicZone, false,
55+
"unknown", false, []interface{}{ publicZoneStr },
10256
},
10357
} {
10458
zoneTypeFilter := NewZoneTypeFilter(tc.zoneTypeFilter)
105-
assert.Equal(t, tc.matches, zoneTypeFilter.Match(tc.zone))
59+
for _, zone := range tc.zones {
60+
assert.Equal(t, tc.matches, zoneTypeFilter.Match(zone))
61+
}
10662
}
10763
}

0 commit comments

Comments
 (0)