diff options
Diffstat (limited to 'skate/zipkey/batch_test.go')
-rw-r--r-- | skate/zipkey/batch_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/skate/zipkey/batch_test.go b/skate/zipkey/batch_test.go new file mode 100644 index 0000000..7c6a48c --- /dev/null +++ b/skate/zipkey/batch_test.go @@ -0,0 +1,32 @@ +package zipkey + +import ( + "bytes" + "encoding/json" + "strings" + "testing" +) + +func TestBatcher(t *testing.T) { + var ( + buf bytes.Buffer + enc = json.NewEncoder(&buf) + f = func(g *Group) error { + return enc.Encode(g) + } + b = NewBatcher(groupFunc(f)) + ) + b.GroupFunc(&Group{ + Key: "K1", + G0: []string{"A"}, + G1: []string{"B"}, + }) + b.Close() + var ( + got = strings.TrimSpace(buf.String()) + want = `{"Key":"K1","G0":["A"],"G1":["B"]}` + ) + if got != want { + t.Fatalf("got %v, want %v", got, want) + } +} |