Port 'docker images' to the engine API

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
Solomon Hykes
2014-01-13 15:49:33 -08:00
committed by Victor Vieux
parent 6652416f4c
commit 17a806c8a0
10 changed files with 270 additions and 175 deletions
+28
View File
@@ -0,0 +1,28 @@
package engine
import (
"testing"
"bytes"
"encoding/json"
)
func TestTableWriteTo(t *testing.T) {
table := NewTable("", 0)
e := &Env{}
e.Set("foo", "bar")
table.Add(e)
var buf bytes.Buffer
if _, err := table.WriteTo(&buf); err != nil {
t.Fatal(err)
}
output := make(map[string]string)
if err := json.Unmarshal(buf.Bytes(), &output); err != nil {
t.Fatal(err)
}
if len(output) != 1 {
t.Fatalf("Incorrect output: %v", output)
}
if val, exists := output["foo"]; !exists || val != "bar" {
t.Fatalf("Inccorect output: %v", output)
}
}