diff --git a/staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator/priority_test.go b/staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator/priority_test.go index 085ed15fd61..c36492f439f 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator/priority_test.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator/priority_test.go @@ -25,12 +25,12 @@ import ( "k8s.io/kube-aggregator/pkg/apis/apiregistration" ) -func newAPIServiceForTest(name, group string, minGroupPriority, versionPriority int32) apiregistration.APIService { +func newAPIServiceForTest(name, group string, minGroupPriority, versionPriority int32, svc *apiregistration.ServiceReference) apiregistration.APIService { r := apiregistration.APIService{} r.Spec.Group = group r.Spec.GroupPriorityMinimum = minGroupPriority r.Spec.VersionPriority = versionPriority - r.Spec.Service = &apiregistration.ServiceReference{} + r.Spec.Service = svc r.Name = name return r } @@ -48,22 +48,31 @@ func assertSortedServices(t *testing.T, actual []openAPISpecInfo, expectedNames func TestAPIServiceSort(t *testing.T) { list := []openAPISpecInfo{ { - apiService: newAPIServiceForTest("FirstService", "Group1", 10, 5), + apiService: newAPIServiceForTest("FirstService", "Group1", 10, 5, &apiregistration.ServiceReference{}), spec: &spec.Swagger{}, }, { - apiService: newAPIServiceForTest("SecondService", "Group2", 15, 3), + apiService: newAPIServiceForTest("SecondService", "Group2", 15, 3, &apiregistration.ServiceReference{}), spec: &spec.Swagger{}, }, { - apiService: newAPIServiceForTest("FirstServiceInternal", "Group1", 16, 3), + apiService: newAPIServiceForTest("FirstServiceInternal", "Group1", 16, 3, &apiregistration.ServiceReference{}), spec: &spec.Swagger{}, }, { - apiService: newAPIServiceForTest("ThirdService", "Group3", 15, 3), + apiService: newAPIServiceForTest("ThirdService", "Group3", 15, 3, &apiregistration.ServiceReference{}), spec: &spec.Swagger{}, }, + { + apiService: newAPIServiceForTest("local_service_1", "Group4", 15, 1, nil), + }, + { + apiService: newAPIServiceForTest("local_service_3", "Group5", 15, 2, nil), + }, + { + apiService: newAPIServiceForTest("local_service_2", "Group6", 15, 3, nil), + }, } sortByPriority(list) - assertSortedServices(t, list, []string{"FirstService", "FirstServiceInternal", "SecondService", "ThirdService"}) + assertSortedServices(t, list, []string{"local_service_1", "local_service_2", "local_service_3", "FirstService", "FirstServiceInternal", "SecondService", "ThirdService"}) }