diff options
author | Martin Kobetic <mkobetic@gmail.com> | 2014-05-09 18:16:38 +0000 |
---|---|---|
committer | Martin Kobetic <mkobetic@gmail.com> | 2014-05-09 20:50:58 +0000 |
commit | c4ad027df774d84c29c9cc53436071c87138c60d (patch) | |
tree | f2a26eeea973f9fe25a7f4957361052563175a80 /cmd/bolt/stats_test.go | |
parent | first part (diff) | |
download | dedo-c4ad027df774d84c29c9cc53436071c87138c60d.tar.gz dedo-c4ad027df774d84c29c9cc53436071c87138c60d.tar.xz |
aggregate bucket stats recursively and add stats to cmd
Diffstat (limited to 'cmd/bolt/stats_test.go')
-rw-r--r-- | cmd/bolt/stats_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cmd/bolt/stats_test.go b/cmd/bolt/stats_test.go new file mode 100644 index 0000000..9662f09 --- /dev/null +++ b/cmd/bolt/stats_test.go @@ -0,0 +1,37 @@ +package main_test + +import ( + "testing" + + "github.com/boltdb/bolt" + . "github.com/boltdb/bolt/cmd/bolt" + "github.com/stretchr/testify/assert" +) + +func TestStats(t *testing.T) { + SetTestMode(true) + open(func(db *bolt.DB, path string) { + db.Update(func(tx *bolt.Tx) error { + tx.CreateBucket([]byte("foo")) + tx.CreateBucket([]byte("bar")) + tx.CreateBucket([]byte("baz")) + return nil + }) + db.Close() + output := run("stats", path, "b") + assert.Equal(t, "Aggregate statistics for 2 buckets\n\n"+ + "Page count statistics\n"+ + "\tNumber of logical branch pages: 0\n"+ + "\tNumber of physical branch overflow pages: 0\n"+ + "\tNumber of logical leaf pages: 2\n"+ + "\tNumber of physical leaf overflow pages: 0\n"+ + "Tree statistics\n"+ + "\tNumber of keys/value pairs: 0\n"+ + "\tNumber of levels in B+tree: 0\n"+ + "Page size utilization\n"+ + "\tBytes allocated for physical branch pages: 0\n"+ + "\tBytes actually used for branch data: 0\n"+ + "\tBytes allocated for physical leaf pages: 8192\n"+ + "\tBytes actually used for leaf data: 0", output) + }) +} |