Merge pull request #24851 from pmorie/master-test-loc

Automatic merge from submit-queue

Reduce LOC in third party controller test

Extract method refactor to make this test a little more readable

@kubernetes/sig-api-machinery
pull/6/head
k8s-merge-robot 2016-04-27 05:53:33 -07:00
commit a8d9a8dafd
1 changed files with 13 additions and 40 deletions

View File

@ -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",