Skip to content

Commit

Permalink
Move echoSource into targetfiltersource_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
BadLiveware committed May 17, 2023
1 parent 519880d commit a55ae00
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 87 deletions.
41 changes: 0 additions & 41 deletions source/echo.go

This file was deleted.

46 changes: 0 additions & 46 deletions source/echo_test.go

This file was deleted.

41 changes: 41 additions & 0 deletions source/targetfiltersource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,47 @@ import (
"sigs.k8s.io/external-dns/endpoint"
)

// echoSource is a Source that returns the endpoints passed in on creation.
type echoSource struct {
endpoints []*endpoint.Endpoint
}

func (e *echoSource) AddEventHandler(ctx context.Context, handler func()) {
}

// Endpoints returns all of the endpoints passed in on creation
func (e *echoSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error) {
return e.endpoints, nil
}

// NewEchoSource creates a new echoSource.
func NewEchoSource(endpoints []*endpoint.Endpoint) Source {
return &echoSource{endpoints: endpoints}
}

func TestEchoSourceReturnGivenSources(t *testing.T) {
startEndpoints := []*endpoint.Endpoint{{
DNSName: "foo.bar.com",
RecordType: "A",
Targets: endpoint.Targets{"1.2.3.4"},
RecordTTL: endpoint.TTL(300),
Labels: endpoint.Labels{},
}}
e := NewEchoSource(startEndpoints)

endpoints, err := e.Endpoints(context.Background())
if err != nil {
t.Errorf("Expected no error but got %s", err.Error())
}

for i, endpoint := range endpoints {
if endpoint != startEndpoints[i] {
t.Errorf("Expected %s but got %s", startEndpoints[i], endpoint)
}
}
}


func TestTargetFilterSource(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit a55ae00

Please sign in to comment.