Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions source/wrappers/multisource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ func testMultiSourceImplementsSource(t *testing.T) {

// testMultiSourceEndpoints tests merged endpoints from children are returned.
func testMultiSourceEndpoints(t *testing.T) {
foo := &endpoint.Endpoint{DNSName: "foo", Targets: endpoint.Targets{"8.8.8.8"}}
bar := &endpoint.Endpoint{DNSName: "bar", Targets: endpoint.Targets{"8.8.4.4"}}

for _, tc := range []struct {
title string
nestedEndpoints [][]*endpoint.Endpoint
Expand All @@ -65,19 +62,26 @@ func testMultiSourceEndpoints(t *testing.T) {
},
{
"single non-empty child source returns child's endpoints",
[][]*endpoint.Endpoint{{foo}},
[]*endpoint.Endpoint{foo},
[][]*endpoint.Endpoint{
{&endpoint.Endpoint{DNSName: "foo", Targets: endpoint.Targets{"8.8.8.8"}}},
},
[]*endpoint.Endpoint{
{DNSName: "foo", Targets: endpoint.Targets{"8.8.8.8"}},
},
},
{
"multiple non-empty child sources returns merged children's endpoints",
[][]*endpoint.Endpoint{{foo}, {bar}},
[]*endpoint.Endpoint{foo, bar},
[][]*endpoint.Endpoint{{
&endpoint.Endpoint{DNSName: "foo", Targets: endpoint.Targets{"8.8.8.8"}},
}, {
&endpoint.Endpoint{DNSName: "bar", Targets: endpoint.Targets{"8.8.4.4"}}}},
[]*endpoint.Endpoint{
{DNSName: "foo", Targets: endpoint.Targets{"8.8.8.8"}},
{DNSName: "bar", Targets: endpoint.Targets{"8.8.4.4"}}},
},
} {

t.Run(tc.title, func(t *testing.T) {
t.Parallel()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the use of independent endpoints, is this needed?


// Prepare the nested mock sources.
sources := make([]source.Source, 0, len(tc.nestedEndpoints))

Expand Down
10 changes: 0 additions & 10 deletions source/wrappers/targetfiltersource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ func TestEchoSourceReturnGivenSources(t *testing.T) {
}
}

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

t.Run("Interface", TestTargetFilterSourceImplementsSource)
t.Run("Endpoints", TestTargetFilterSourceEndpoints)
}

// TestTargetFilterSourceImplementsSource tests that targetFilterSource is a valid Source.
func TestTargetFilterSourceImplementsSource(t *testing.T) {
var _ source.Source = &targetFilterSource{}
Expand Down Expand Up @@ -120,10 +113,7 @@ func TestTargetFilterSourceEndpoints(t *testing.T) {
},
}
for _, tt := range tests {

t.Run(tt.title, func(t *testing.T) {
t.Parallel()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do this cause any issue?


echo := testutils.NewMockSource(tt.endpoints...)
src := NewTargetFilterSource(echo, tt.filters)

Expand Down
Loading