Skip to content

Commit

Permalink
Add a test for JSON encoding
Browse files Browse the repository at this point in the history
This is mostly as an example for how to use it.
  • Loading branch information
rcrowley committed May 10, 2014
1 parent c3fec5e commit 4d17aae
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions json_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package metrics

import (
"bytes"
"encoding/json"
"testing"
)

func TestRegistryMarshallJSON(t *testing.T) {
b := &bytes.Buffer{}
enc := json.NewEncoder(b)
r := NewRegistry()
r.Register("counter", NewCounter())
enc.Encode(r)
if s := b.String(); "{\"counter\":{\"count\":0}}\n" != s {
t.Fatalf(s)
}
}

0 comments on commit 4d17aae

Please sign in to comment.