aboutsummaryrefslogtreecommitdiff
path: root/cmd/bolt/get_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-04-11 13:23:11 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-04-11 14:05:58 -0600
commite6b5fdc30e0398dfe0c08355babf397fb8bfc470 (patch)
tree2210d344b510769e1bbdb7af67d7f0286861fbe3 /cmd/bolt/get_test.go
parentMerge pull request #122 from mkobetic/benchmark_tweaks (diff)
downloaddedo-e6b5fdc30e0398dfe0c08355babf397fb8bfc470.tar.gz
dedo-e6b5fdc30e0398dfe0c08355babf397fb8bfc470.tar.xz
Add import/export to CLI.
This commit adds two new commands: bolt import --input INPUT PATH bolt export PATH This exports the database in a simple, nested, key/value JSON document. Each node in the document has a "key", a "value", and an optional "type". The key and value fields are both base64 encoded.
Diffstat (limited to 'cmd/bolt/get_test.go')
-rw-r--r--cmd/bolt/get_test.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/cmd/bolt/get_test.go b/cmd/bolt/get_test.go
index 4498086..09883d4 100644
--- a/cmd/bolt/get_test.go
+++ b/cmd/bolt/get_test.go
@@ -11,13 +11,14 @@ import (
// Ensure that a value can be retrieved from the CLI.
func TestGet(t *testing.T) {
SetTestMode(true)
- open(func(db *bolt.DB) {
+ open(func(db *bolt.DB, path string) {
db.Update(func(tx *bolt.Tx) error {
tx.CreateBucket("widgets")
tx.Bucket("widgets").Put([]byte("foo"), []byte("bar"))
return nil
})
- output := run("get", db.Path(), "widgets", "foo")
+ db.Close()
+ output := run("get", path, "widgets", "foo")
assert.Equal(t, "bar", output)
})
}
@@ -32,8 +33,9 @@ func TestGetDBNotFound(t *testing.T) {
// Ensure that an error is reported if the bucket is not found.
func TestGetBucketNotFound(t *testing.T) {
SetTestMode(true)
- open(func(db *bolt.DB) {
- output := run("get", db.Path(), "widgets", "foo")
+ open(func(db *bolt.DB, path string) {
+ db.Close()
+ output := run("get", path, "widgets", "foo")
assert.Equal(t, "bucket not found: widgets", output)
})
}
@@ -41,11 +43,12 @@ func TestGetBucketNotFound(t *testing.T) {
// Ensure that an error is reported if the key is not found.
func TestGetKeyNotFound(t *testing.T) {
SetTestMode(true)
- open(func(db *bolt.DB) {
+ open(func(db *bolt.DB, path string) {
db.Update(func(tx *bolt.Tx) error {
return tx.CreateBucket("widgets")
})
- output := run("get", db.Path(), "widgets", "foo")
+ db.Close()
+ output := run("get", path, "widgets", "foo")
assert.Equal(t, "key not found: foo", output)
})
}