From 014982cafcb4b45e3c3a31929306d374798f6acd Mon Sep 17 00:00:00 2001 From: ideahitme Date: Thu, 2 Mar 2017 11:24:23 +0100 Subject: [PATCH] create shared_test and scope service tests --- source/service_test.go | 32 +++++++------------------------- source/shared_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 source/shared_test.go diff --git a/source/service_test.go b/source/service_test.go index dfa51aecd..40aa19ee9 100644 --- a/source/service_test.go +++ b/source/service_test.go @@ -26,8 +26,12 @@ import ( "github.com/kubernetes-incubator/external-dns/endpoint" ) -// TestEndpoints tests that various services generate the correct endpoints. -func TestEndpoints(t *testing.T) { +func TestService(t *testing.T) { + t.Run("Endpoints", testServiceEndpoints) +} + +// testServiceEndpoints tests that various services generate the correct endpoints. +func testServiceEndpoints(t *testing.T) { for _, tc := range []struct { title string namespace string @@ -176,7 +180,7 @@ func TestEndpoints(t *testing.T) { } } -func BenchmarkEndpoints(b *testing.B) { +func BenchmarkServiceEndpoints(b *testing.B) { kubernetes := fake.NewSimpleClientset() service := &v1.Service{ @@ -213,25 +217,3 @@ func BenchmarkEndpoints(b *testing.B) { } } } - -// test helper functions - -func validateEndpoints(t *testing.T, endpoints, expected []endpoint.Endpoint) { - if len(endpoints) != len(expected) { - t.Fatalf("expected %d endpoints, got %d", len(expected), len(endpoints)) - } - - for i := range endpoints { - validateEndpoint(t, endpoints[i], expected[i]) - } -} - -func validateEndpoint(t *testing.T, endpoint, expected endpoint.Endpoint) { - if endpoint.DNSName != expected.DNSName { - t.Errorf("expected %s, got %s", expected.DNSName, endpoint.DNSName) - } - - if endpoint.Target != expected.Target { - t.Errorf("expected %s, got %s", expected.Target, endpoint.Target) - } -} diff --git a/source/shared_test.go b/source/shared_test.go new file mode 100644 index 000000000..22762fdbc --- /dev/null +++ b/source/shared_test.go @@ -0,0 +1,29 @@ +package source + +import ( + "testing" + + "github.com/kubernetes-incubator/external-dns/endpoint" +) + +// test helper functions + +func validateEndpoints(t *testing.T, endpoints, expected []endpoint.Endpoint) { + if len(endpoints) != len(expected) { + t.Fatalf("expected %d endpoints, got %d", len(expected), len(endpoints)) + } + + for i := range endpoints { + validateEndpoint(t, endpoints[i], expected[i]) + } +} + +func validateEndpoint(t *testing.T, endpoint, expected endpoint.Endpoint) { + if endpoint.DNSName != expected.DNSName { + t.Errorf("expected %s, got %s", expected.DNSName, endpoint.DNSName) + } + + if endpoint.Target != expected.Target { + t.Errorf("expected %s, got %s", expected.Target, endpoint.Target) + } +}