func TestEventSearch(t *testing.T) { c := &testClient{ Request: testRequest{ Method: "GET", Path: testapi.ResourcePath("events", "baz", ""), Query: url.Values{ api.FieldSelectorQueryParam(testapi.Version()): []string{ getInvolvedObjectNameFieldLabel(testapi.Version()) + "=foo,", "involvedObject.namespace=baz,", "involvedObject.kind=Pod", }, api.LabelSelectorQueryParam(testapi.Version()): []string{}, }, }, Response: Response{StatusCode: 200, Body: &api.EventList{}}, } eventList, err := c.Setup().Events("baz").Search( &api.Pod{ ObjectMeta: api.ObjectMeta{ Name: "foo", Namespace: "baz", SelfLink: testapi.SelfLink("pods", ""), }, }, ) c.Validate(t, eventList, err) }
// Create a pod with a given index, requiring one port func NewTestPod(i int) *api.Pod { name := fmt.Sprintf("pod%d", i) return &api.Pod{ TypeMeta: api.TypeMeta{APIVersion: testapi.Version()}, ObjectMeta: api.ObjectMeta{ Name: name, Namespace: api.NamespaceDefault, SelfLink: testapi.SelfLink("pods", string(i)), }, Spec: api.PodSpec{ Containers: []api.Container{ { Name: "foo", Ports: []api.ContainerPort{ { ContainerPort: 8000 + i, Protocol: api.ProtocolTCP, }, }, }, }, }, Status: api.PodStatus{ Conditions: []api.PodCondition{ { Type: api.PodReady, Status: api.ConditionTrue, }, }, }, } }
func podWithID(id, desiredHost string) *api.Pod { return &api.Pod{ ObjectMeta: api.ObjectMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)}, Spec: api.PodSpec{ Host: desiredHost, }, } }
func TestEventSearch(t *testing.T) { c := &testClient{ Request: testRequest{ Method: "GET", Path: "/events", Query: url.Values{ "fields": []string{"involvedObject.kind=Pod,involvedObject.name=foo,involvedObject.namespace=baz"}, "labels": []string{}, }, }, Response: Response{StatusCode: 200, Body: &api.EventList{}}, } eventList, err := c.Setup().Events("").Search( &api.Pod{ ObjectMeta: api.ObjectMeta{ Name: "foo", Namespace: "baz", SelfLink: testapi.SelfLink("pods", ""), }, }, ) c.Validate(t, eventList, err) }
func podWithID(id string) *api.Pod { return &api.Pod{ObjectMeta: api.ObjectMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)}} }