From c386850d23ebc40b9e5abebe3e6fb15ac47409af Mon Sep 17 00:00:00 2001 From: Paul Morie Date: Wed, 27 Apr 2016 02:50:46 -0400 Subject: [PATCH] Reduce LOC in third party controller test --- pkg/master/thirdparty_controller_test.go | 53 ++++++------------------ 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/pkg/master/thirdparty_controller_test.go b/pkg/master/thirdparty_controller_test.go index be1b7775637..4b52e899493 100644 --- a/pkg/master/thirdparty_controller_test.go +++ b/pkg/master/thirdparty_controller_test.go @@ -63,6 +63,14 @@ func (f *FakeAPIInterface) ListThirdPartyResources() []string { } func TestSyncAPIs(t *testing.T) { + resourcesNamed := func(names ...string) []expapi.ThirdPartyResource { + result := []expapi.ThirdPartyResource{} + for _, name := range names { + result = append(result, expapi.ThirdPartyResource{ObjectMeta: api.ObjectMeta{Name: name}}) + } + return result + } + tests := []struct { list *expapi.ThirdPartyResourceList apis []string @@ -72,26 +80,14 @@ func TestSyncAPIs(t *testing.T) { }{ { list: &expapi.ThirdPartyResourceList{ - Items: []expapi.ThirdPartyResource{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo.example.com", - }, - }, - }, + Items: resourcesNamed("foo.example.com"), }, expectedInstalled: []string{"foo.example.com"}, name: "simple add", }, { list: &expapi.ThirdPartyResourceList{ - Items: []expapi.ThirdPartyResource{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo.example.com", - }, - }, - }, + Items: resourcesNamed("foo.example.com"), }, apis: []string{ "/apis/example.com", @@ -101,13 +97,7 @@ func TestSyncAPIs(t *testing.T) { }, { list: &expapi.ThirdPartyResourceList{ - Items: []expapi.ThirdPartyResource{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo.example.com", - }, - }, - }, + Items: resourcesNamed("foo.example.com"), }, apis: []string{ "/apis/example.com", @@ -123,18 +113,7 @@ func TestSyncAPIs(t *testing.T) { }, { list: &expapi.ThirdPartyResourceList{ - Items: []expapi.ThirdPartyResource{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo.example.com", - }, - }, - { - ObjectMeta: api.ObjectMeta{ - Name: "foo.company.com", - }, - }, - }, + Items: resourcesNamed("foo.example.com", "foo.company.com"), }, apis: []string{ "/apis/company.com", @@ -145,13 +124,7 @@ func TestSyncAPIs(t *testing.T) { }, { list: &expapi.ThirdPartyResourceList{ - Items: []expapi.ThirdPartyResource{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo.example.com", - }, - }, - }, + Items: resourcesNamed("foo.example.com"), }, apis: []string{ "/apis/company.com",