Permalink
Browse files

add some more tests to make it closer to W3C tests

  • Loading branch information...
1 parent ce4d9a2 commit 3f7b84626b3d966507f3414d1a0fcb2924c11dbe eaceaser committed Mar 26, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 src/test/scala/com/twitter/ostrich/stats/JsonStatsSpec.scala
@@ -29,6 +29,15 @@ object JsonStatsSpec extends Specification {
handler.clear()
}
+ "can be called manually" in {
+ val counters = Map("widgets" -> 3L)
+ val gauges = Map("wodgets" -> 3.5)
+ val metrics = Map("timing_msec" -> new Distribution(1, 10, 10, 10))
+ val labels = Map("this" -> "that")
+ json.write(StatsSummary(counters, metrics, gauges, labels))
+ getLine() mustEqual """{"timing_msec":10,"wodgets":3.5,"widgets":3,"this":"that"}"""
+ }
+
"can be called transactionally" in {
json { stats =>
stats.setLabel("test", "blah")
@@ -47,5 +56,13 @@ object JsonStatsSpec extends Specification {
map("test2") mustEqual "crap"
map("test-time_msec").asInstanceOf[Int] must be_>=(0)
}
+
+ "sum counts within a transaction" in {
+ json { stats =>
+ stats.incr("test", 8)
+ stats.incr("test", 8)
+ }
+ getLine() mustEqual """{"test":16}"""
+ }
}
}

0 comments on commit 3f7b846

Please sign in to comment.