make kubectl get generic with respect to objects

This commit is contained in:
deads2k
2016-11-02 12:29:01 -04:00
parent 7fe9bd4c30
commit 61673c4b39
16 changed files with 410 additions and 394 deletions

View File

@@ -229,6 +229,27 @@ func TestSetListToRuntimeObjectArray(t *testing.T) {
}
}
func TestSetListToMatchingType(t *testing.T) {
pl := &runtime.UnstructuredList{}
list := []runtime.Object{
&runtime.Unstructured{Object: map[string]interface{}{"foo": 1}},
&runtime.Unstructured{Object: map[string]interface{}{"foo": 2}},
&runtime.Unstructured{Object: map[string]interface{}{"foo": 3}},
}
err := meta.SetList(pl, list)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
if e, a := len(list), len(pl.Items); e != a {
t.Fatalf("Expected %v, got %v", e, a)
}
for i := range list {
if e, a := list[i], pl.Items[i]; e != a {
t.Fatalf("%d: unmatched: %s", i, diff.ObjectDiff(e, a))
}
}
}
func TestSetExtractListRoundTrip(t *testing.T) {
fuzzer := fuzz.New().NilChance(0).NumElements(1, 5)
for i := 0; i < 5; i++ {