From 50e04a29aeebe461fe9d00ec780246ac3a222c09 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Thu, 8 May 2014 08:43:18 -0600 Subject: Add 'bolt info'. --- cmd/bolt/info_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cmd/bolt/info_test.go (limited to 'cmd/bolt/info_test.go') diff --git a/cmd/bolt/info_test.go b/cmd/bolt/info_test.go new file mode 100644 index 0000000..668cc61 --- /dev/null +++ b/cmd/bolt/info_test.go @@ -0,0 +1,32 @@ +package main_test + +import ( + "testing" + + "github.com/boltdb/bolt" + . "github.com/boltdb/bolt/cmd/bolt" + "github.com/stretchr/testify/assert" +) + +// Ensure that a database info can be printed. +func TestInfo(t *testing.T) { + SetTestMode(true) + open(func(db *bolt.DB, path string) { + db.Update(func(tx *bolt.Tx) error { + tx.CreateBucket([]byte("widgets")) + b := tx.Bucket([]byte("widgets")) + b.Put([]byte("foo"), []byte("0000")) + return nil + }) + db.Close() + output := run("info", path) + assert.Equal(t, `Page Size: 4096`, output) + }) +} + +// Ensure that an error is reported if the database is not found. +func TestInfo_NotFound(t *testing.T) { + SetTestMode(true) + output := run("info", "no/such/db") + assert.Equal(t, "stat no/such/db: no such file or directory", output) +} -- cgit v1.2.3