util.EncodeJSON proven harmful, remove it everywhere

People were misusing EncodeJSON in tests when they should be using
runtime.EncodeOrDie(testapi.Codec(), obj).  Removing the potential
for cutting self on sharp objects.
This commit is contained in:
Clayton Coleman
2014-11-13 10:38:13 -05:00
parent d4108ec47e
commit 6d31c2bf8a
7 changed files with 49 additions and 81 deletions

View File

@@ -24,39 +24,6 @@ import (
"gopkg.in/v1/yaml"
)
type FakeTypeMeta struct {
ID string
}
type FakePod struct {
FakeTypeMeta `json:",inline" yaml:",inline"`
Labels map[string]string
Int int
Str string
}
func TestEncodeJSON(t *testing.T) {
pod := FakePod{
FakeTypeMeta: FakeTypeMeta{ID: "foo"},
Labels: map[string]string{
"foo": "bar",
"baz": "blah",
},
Int: -6,
Str: "a string",
}
body := EncodeJSON(pod)
expectedBody, err := json.Marshal(pod)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if string(expectedBody) != body {
t.Errorf("JSON doesn't match. Expected %s, saw %s", expectedBody, body)
}
}
func TestHandleCrash(t *testing.T) {
count := 0
expect := 10