Skip to content

Commit 35f3202

Browse files
committed
Test ZoneHasPaidPlan
1 parent 94f4c69 commit 35f3202

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

provider/cloudflare/cloudflare_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,9 @@ func (m *mockCloudFlareClient) ZoneDetails(ctx context.Context, zoneID string) (
426426
return cloudflare.Zone{
427427
ID: zoneID,
428428
Name: zoneName,
429+
Plan: cloudflare.ZonePlan{
430+
IsSubscribed: strings.HasSuffix(zoneName, "bar.com"),
431+
},
429432
}, nil
430433
}
431434
}
@@ -902,6 +905,27 @@ func TestCloudflareZones(t *testing.T) {
902905
assert.Equal(t, "bar.com", zones[0].Name)
903906
}
904907

908+
func TestZoneHasPaidPlan(t *testing.T) {
909+
provider := &CloudFlareProvider{
910+
Client: NewMockCloudFlareClient(),
911+
domainFilter: endpoint.NewDomainFilter([]string{"foo.com", "bar.com"}),
912+
zoneIDFilter: provider.NewZoneIDFilter([]string{""}),
913+
}
914+
915+
fooZoneHasPaidPlan, err := provider.ZoneHasPaidPlan("subdomain.foo.com")
916+
if err != nil {
917+
t.Fatal(err)
918+
}
919+
assert.Equal(t, false, fooZoneHasPaidPlan)
920+
921+
barZoneHasPaidPlan, err := provider.ZoneHasPaidPlan("subdomain.bar.com")
922+
if err != nil {
923+
t.Fatal(err)
924+
}
925+
assert.Equal(t, true, barZoneHasPaidPlan)
926+
927+
}
928+
905929
// test failures on zone lookup
906930
func TestCloudflareZonesFailed(t *testing.T) {
907931

0 commit comments

Comments
 (0)