Merge branch 'master' into ingress/basic-support

This commit is contained in:
ideahitme 2017-03-02 12:04:46 +01:00
commit d89a94e928
3 changed files with 58 additions and 28 deletions

View File

@ -28,9 +28,12 @@ cover-html: cover
# The verify target runs tasks similar to the CI tasks, but without code coverage
.PHONY: verify
.PHONY: verify test
verify:
test:
go test -v $(shell go list ./... | grep -v /vendor/)
verify: test
vendor/github.com/kubernetes/repo-infra/verify/verify-boilerplate.sh --rootdir=${CURDIR}
vendor/github.com/kubernetes/repo-infra/verify/verify-go-src.sh -v --rootdir ${CURDIR}
go test -v $(shell go list ./... | grep -v /vendor/)

View File

@ -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)
}
}

45
source/shared_test.go Normal file
View File

@ -0,0 +1,45 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
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)
}
}