コード例 #1
0
func TestExtractJson(t *testing.T) {
	mockRegistry := MockPodRegistry{}
	storage := PodRegistryStorage{
		registry: &mockRegistry,
	}
	pod := api.Pod{
		JSONBase: api.JSONBase{
			ID: "foo",
		},
	}
	body, err := json.Marshal(pod)
	expectNoError(t, err)
	podOut, err := storage.Extract(string(body))
	expectNoError(t, err)
	// Extract adds in a kind
	pod.Kind = "cluster#pod"
	if !reflect.DeepEqual(pod, podOut) {
		t.Errorf("Expected %#v, found %#v", pod, podOut)
	}
}
コード例 #2
0
ファイル: pod_registry.go プロジェクト: happywky/kubernetes
func (storage *PodRegistryStorage) Extract(body string) (interface{}, error) {
	pod := api.Pod{}
	err := json.Unmarshal([]byte(body), &pod)
	pod.Kind = "cluster#pod"
	return pod, err
}