mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #2891 from rajdeepd/master
Added test case for events Create
This commit is contained in:
commit
ad4185ef3a
@ -18,10 +18,12 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEventSearch(t *testing.T) {
|
func TestEventSearch(t *testing.T) {
|
||||||
@ -47,3 +49,39 @@ func TestEventSearch(t *testing.T) {
|
|||||||
)
|
)
|
||||||
c.Validate(t, eventList, err)
|
c.Validate(t, eventList, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEventCreate(t *testing.T) {
|
||||||
|
objReference := &api.ObjectReference{
|
||||||
|
Kind: "foo",
|
||||||
|
Namespace: "nm",
|
||||||
|
Name: "objref1",
|
||||||
|
UID: "uid",
|
||||||
|
APIVersion: "apiv1",
|
||||||
|
ResourceVersion: "1",
|
||||||
|
}
|
||||||
|
timeStamp := util.Now()
|
||||||
|
event := &api.Event{
|
||||||
|
//namespace: namespace{"default"},
|
||||||
|
Status: "running",
|
||||||
|
InvolvedObject: *objReference,
|
||||||
|
Timestamp: timeStamp,
|
||||||
|
}
|
||||||
|
c := &testClient{
|
||||||
|
Request: testRequest{
|
||||||
|
Method: "POST",
|
||||||
|
Path: "/events",
|
||||||
|
Body: event,
|
||||||
|
},
|
||||||
|
Response: Response{StatusCode: 200, Body: event},
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := c.Setup().Events("").Create(event)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%#v should be nil.", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if e, a := *objReference, response.InvolvedObject; !reflect.DeepEqual(e, a) {
|
||||||
|
t.Errorf("%#v != %#v.", e, a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user