Add namespaces to event creation path.
This commit is contained in:
@@ -19,6 +19,7 @@ package record_test
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
@@ -55,9 +56,10 @@ func TestEventf(t *testing.T) {
|
||||
{
|
||||
obj: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
SelfLink: "/api/v1beta1/pods/foo",
|
||||
Name: "foo",
|
||||
UID: "bar",
|
||||
SelfLink: "/api/v1beta1/pods/foo",
|
||||
Name: "foo",
|
||||
Namespace: "baz",
|
||||
UID: "bar",
|
||||
},
|
||||
},
|
||||
fieldPath: "desiredState.manifest.containers[2]",
|
||||
@@ -66,9 +68,14 @@ func TestEventf(t *testing.T) {
|
||||
messageFmt: "some verbose message: %v",
|
||||
elements: []interface{}{1},
|
||||
expect: &api.Event{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "baz",
|
||||
},
|
||||
InvolvedObject: api.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Name: "foo",
|
||||
Namespace: "baz",
|
||||
UID: "bar",
|
||||
APIVersion: "v1beta1",
|
||||
FieldPath: "desiredState.manifest.containers[2]",
|
||||
@@ -78,7 +85,7 @@ func TestEventf(t *testing.T) {
|
||||
Message: "some verbose message: 1",
|
||||
Source: "eventTest",
|
||||
},
|
||||
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): status: 'running', reason: 'started' some verbose message: 1`,
|
||||
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): status: 'running', reason: 'started' some verbose message: 1`,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -92,6 +99,11 @@ func TestEventf(t *testing.T) {
|
||||
t.Errorf("timestamp wasn't set")
|
||||
}
|
||||
a.Timestamp = item.expect.Timestamp
|
||||
// Check that name has the right prefix.
|
||||
if n, en := a.Name, item.expect.Name; !strings.HasPrefix(n, en) {
|
||||
t.Errorf("Name '%v' does not contain prefix '%v'", n, en)
|
||||
}
|
||||
a.Name = item.expect.Name
|
||||
if e, a := item.expect, &a; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("diff: %s", util.ObjectDiff(e, a))
|
||||
}
|
||||
|
Reference in New Issue
Block a user