mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 01:26:59 +02:00
Refactor zone type test
This commit is contained in:
parent
b8cee43d73
commit
afe9381b48
@ -25,83 +25,39 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestZoneTypeFilterMatchAWS(t *testing.T) {
|
||||
publicZone := &route53.HostedZone{Config: &route53.HostedZoneConfig{PrivateZone: aws.Bool(false)}}
|
||||
privateZone := &route53.HostedZone{Config: &route53.HostedZoneConfig{PrivateZone: aws.Bool(true)}}
|
||||
|
||||
for _, tc := range []struct {
|
||||
zoneTypeFilter string
|
||||
zone *route53.HostedZone
|
||||
matches bool
|
||||
}{
|
||||
{
|
||||
"", publicZone, true,
|
||||
},
|
||||
{
|
||||
"", privateZone, true,
|
||||
},
|
||||
{
|
||||
"public", publicZone, true,
|
||||
},
|
||||
{
|
||||
"public", privateZone, false,
|
||||
},
|
||||
{
|
||||
"private", publicZone, false,
|
||||
},
|
||||
{
|
||||
"private", privateZone, true,
|
||||
},
|
||||
{
|
||||
"unknown", publicZone, false,
|
||||
},
|
||||
{
|
||||
"", &route53.HostedZone{}, true,
|
||||
},
|
||||
{
|
||||
"public", &route53.HostedZone{}, true,
|
||||
},
|
||||
{
|
||||
"private", &route53.HostedZone{}, false,
|
||||
},
|
||||
} {
|
||||
zoneTypeFilter := NewZoneTypeFilter(tc.zoneTypeFilter)
|
||||
assert.Equal(t, tc.matches, zoneTypeFilter.Match(tc.zone))
|
||||
}
|
||||
}
|
||||
|
||||
func TestZoneTypeFilterMatch(t *testing.T) {
|
||||
publicZone := "public"
|
||||
privateZone := "private"
|
||||
publicZoneStr := "public"
|
||||
privateZoneStr := "private"
|
||||
publicZoneAWS := &route53.HostedZone{Config: &route53.HostedZoneConfig{PrivateZone: aws.Bool(false)}}
|
||||
privateZoneAWS := &route53.HostedZone{Config: &route53.HostedZoneConfig{PrivateZone: aws.Bool(true)}}
|
||||
|
||||
for _, tc := range []struct {
|
||||
zoneTypeFilter string
|
||||
zone string
|
||||
matches bool
|
||||
zones []interface{}
|
||||
}{
|
||||
{
|
||||
"", publicZone, true,
|
||||
"", true, []interface{}{ publicZoneStr, privateZoneStr, &route53.HostedZone{} },
|
||||
},
|
||||
{
|
||||
"", privateZone, true,
|
||||
"public", true, []interface{}{ publicZoneStr, publicZoneAWS, &route53.HostedZone{} },
|
||||
},
|
||||
{
|
||||
"public", publicZone, true,
|
||||
"public", false, []interface{}{ privateZoneStr, privateZoneAWS },
|
||||
},
|
||||
{
|
||||
"public", privateZone, false,
|
||||
"private", true, []interface{}{ privateZoneStr, privateZoneAWS },
|
||||
},
|
||||
{
|
||||
"private", publicZone, false,
|
||||
"private", false, []interface{}{ publicZoneStr, publicZoneAWS, &route53.HostedZone{} },
|
||||
},
|
||||
{
|
||||
"private", privateZone, true,
|
||||
},
|
||||
{
|
||||
"unknown", publicZone, false,
|
||||
"unknown", false, []interface{}{ publicZoneStr },
|
||||
},
|
||||
} {
|
||||
zoneTypeFilter := NewZoneTypeFilter(tc.zoneTypeFilter)
|
||||
assert.Equal(t, tc.matches, zoneTypeFilter.Match(tc.zone))
|
||||
for _, zone := range tc.zones {
|
||||
assert.Equal(t, tc.matches, zoneTypeFilter.Match(zone))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user