Fixup event object reference generation to allow downstream objects to have an event

This commit is contained in:
derekwaynecarr
2015-04-20 23:47:55 -04:00
parent 74d6f30b3c
commit 3445bd5806
3 changed files with 66 additions and 19 deletions

View File

@@ -27,6 +27,13 @@ type FakeAPIObject struct{}
func (*FakeAPIObject) IsAnAPIObject() {}
type ExtensionAPIObject struct {
TypeMeta
ObjectMeta
}
func (*ExtensionAPIObject) IsAnAPIObject() {}
func TestGetReference(t *testing.T) {
table := map[string]struct {
obj runtime.Object
@@ -66,6 +73,26 @@ func TestGetReference(t *testing.T) {
ResourceVersion: "42",
},
},
"extensionAPIObject": {
obj: &ExtensionAPIObject{
TypeMeta: TypeMeta{
Kind: "ExtensionAPIObject",
},
ObjectMeta: ObjectMeta{
Name: "foo",
UID: "bar",
ResourceVersion: "42",
SelfLink: "/custom_prefix/version1/extensions/foo",
},
},
ref: &ObjectReference{
Kind: "ExtensionAPIObject",
APIVersion: "version1",
Name: "foo",
UID: "bar",
ResourceVersion: "42",
},
},
"badSelfLink": {
obj: &ServiceList{
ListMeta: ListMeta{
@@ -90,7 +117,7 @@ func TestGetReference(t *testing.T) {
for name, item := range table {
ref, err := GetPartialReference(item.obj, item.fieldPath)
if e, a := item.shouldErr, (err != nil); e != a {
t.Errorf("%v: expected %v, got %v", name, e, a)
t.Errorf("%v: expected %v, got %v, err %v", name, e, a, err)
continue
}
if e, a := item.ref, ref; !reflect.DeepEqual(e, a) {