func TestGetServiceList(t *testing.T) {
	cases := []struct {
		serviceList     *api.ServiceList
		expectedActions []string
		expected        *ServiceList
	}{
		{
			serviceList:     &api.ServiceList{},
			expectedActions: []string{"list"},
			expected:        &ServiceList{Services: make([]Service, 0)},
		}, {
			serviceList: &api.ServiceList{
				Items: []api.Service{
					{ObjectMeta: api.ObjectMeta{
						Name: "test-service", Namespace: "test-namespace",
					}},
				}},
			expectedActions: []string{"list"},
			expected: &ServiceList{
				Services: []Service{
					{
						ObjectMeta: common.ObjectMeta{
							Name:      "test-service",
							Namespace: "test-namespace",
						},
						TypeMeta:         common.TypeMeta{Kind: common.ResourceKindService},
						InternalEndpoint: common.Endpoint{Host: "test-service.test-namespace"},
					},
				},
			},
		},
	}

	for _, c := range cases {
		fakeClient := testclient.NewSimpleFake(c.serviceList)

		actual, _ := GetServiceList(fakeClient, common.NewNamespaceQuery(nil))

		actions := fakeClient.Actions()
		if len(actions) != len(c.expectedActions) {
			t.Errorf("Unexpected actions: %v, expected %d actions got %d", actions,
				len(c.expectedActions), len(actions))
			continue
		}

		for i, verb := range c.expectedActions {
			if actions[i].GetVerb() != verb {
				t.Errorf("Unexpected action: %+v, expected %s",
					actions[i], verb)
			}
		}

		if !reflect.DeepEqual(actual, c.expected) {
			t.Errorf("GetServiceList(client) == got\n%#v, expected\n %#v", actual, c.expected)
		}
	}
}
// parseNamespacePathParameter parses namespace selector for list pages in path paramater.
// The namespace selector is a comma separated list of namespaces that are trimmed.
// No namespaces means "view all user namespaces", i.e., everything except kube-system.
func parseNamespacePathParameter(request *restful.Request) *common.NamespaceQuery {
	namespace := request.PathParameter("namespace")
	namespaces := strings.Split(namespace, ",")
	var nonEmptyNamespaces []string
	for _, n := range namespaces {
		n = strings.Trim(n, " ")
		if len(n) > 0 {
			nonEmptyNamespaces = append(nonEmptyNamespaces, n)
		}
	}
	return common.NewNamespaceQuery(nonEmptyNamespaces)
}