diff --git a/internal/testutils/endpoint.go b/internal/testutils/endpoint.go index e7bd9f987..c98241535 100644 --- a/internal/testutils/endpoint.go +++ b/internal/testutils/endpoint.go @@ -16,9 +16,7 @@ limitations under the License. package testutils -import ( - "github.com/kubernetes-incubator/external-dns/endpoint" -) +import "github.com/kubernetes-incubator/external-dns/endpoint" /** test utility functions for endpoints verifications */ @@ -69,3 +67,9 @@ func SameEndpoints(a, b []*endpoint.Endpoint) bool { return true } + +// SamePlanChanges verifies that two set of changes are the same +func SamePlanChanges(a, b map[string][]*endpoint.Endpoint) bool { + return SameEndpoints(a["Create"], b["Create"]) && SameEndpoints(a["Delete"], b["Delete"]) && + SameEndpoints(a["UpdateOld"], b["UpdateOld"]) && SameEndpoints(a["UpdateNew"], b["UpdateNew"]) +} diff --git a/provider/inmemory.go b/provider/inmemory.go index 5acd42152..c6d2ab9ef 100644 --- a/provider/inmemory.go +++ b/provider/inmemory.go @@ -44,7 +44,7 @@ type zone map[string][]*InMemoryRecord // initialized as dns provider with no records type InMemoryProvider struct { zones map[string]zone - OnApplyChanges func() + OnApplyChanges func(changes *plan.Changes) OnRecords func() } @@ -52,7 +52,7 @@ type InMemoryProvider struct { func NewInMemoryProvider() *InMemoryProvider { return &InMemoryProvider{ zones: map[string]zone{}, - OnApplyChanges: func() {}, + OnApplyChanges: func(changes *plan.Changes) {}, OnRecords: func() {}, } } @@ -92,7 +92,7 @@ func (im *InMemoryProvider) Records(zone string) ([]*endpoint.Endpoint, error) { // update/delete record - record should exist // create/update/delete lists should not have overlapping records func (im *InMemoryProvider) ApplyChanges(zone string, changes *plan.Changes) error { - defer im.OnApplyChanges() + defer im.OnApplyChanges(changes) if err := im.validateChangeBatch(zone, changes); err != nil { return err