func TestExtractControllerJson(t *testing.T) { mockRegistry := MockControllerRegistry{} storage := ControllerRegistryStorage{ registry: &mockRegistry, } controller := api.ReplicationController{ JSONBase: api.JSONBase{ ID: "foo", }, } body, err := json.Marshal(controller) expectNoError(t, err) controllerOut, err := storage.Extract(string(body)) expectNoError(t, err) // Extract adds a Kind controller.Kind = "cluster#replicationController" if !reflect.DeepEqual(controller, controllerOut) { t.Errorf("Expected %#v, found %#v", controller, controllerOut) } }
func (storage *ControllerRegistryStorage) Extract(body string) (interface{}, error) { result := api.ReplicationController{} err := json.Unmarshal([]byte(body), &result) result.Kind = "cluster#replicationController" return result, err }