diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-04-11 14:59:46 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-04-11 14:59:46 -0600 |
commit | 10fed5f74d44caad8f777a38db735ebb7fb3e65b (patch) | |
tree | 125c24e03c653417ce8bf5965b7fbcbeb2dedb04 /cmd/bolt/import_test.go | |
parent | Merge branch 'master' into nested-keys (diff) | |
download | dedo-10fed5f74d44caad8f777a38db735ebb7fb3e65b.tar.gz dedo-10fed5f74d44caad8f777a38db735ebb7fb3e65b.tar.xz |
Upgrade import/export to use nested buckets.
Diffstat (limited to 'cmd/bolt/import_test.go')
-rw-r--r-- | cmd/bolt/import_test.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cmd/bolt/import_test.go b/cmd/bolt/import_test.go index be41f5c..263f561 100644 --- a/cmd/bolt/import_test.go +++ b/cmd/bolt/import_test.go @@ -15,7 +15,7 @@ func TestImport(t *testing.T) { // Write input file. input := tempfile() - assert.NoError(t, ioutil.WriteFile(input, []byte(`[{"type":"bucket","key":"d2lkZ2V0cw==","value":[{"key":"YmFy","value":""},{"key":"Zm9v","value":"MDAwMA=="}]},{"type":"bucket","key":"d29vaml0cw==","value":[{"key":"YmF6","value":"WFhYWA=="}]}]`), 0600)) + assert.NoError(t, ioutil.WriteFile(input, []byte(`[{"type":"bucket","key":"ZW1wdHk=","value":[]},{"type":"bucket","key":"d2lkZ2V0cw==","value":[{"key":"YmFy","value":""},{"key":"Zm9v","value":"MDAwMA=="}]},{"type":"bucket","key":"d29vaml0cw==","value":[{"key":"YmF6","value":"WFhYWA=="},{"type":"bucket","key":"d29vaml0cy9zdWJidWNrZXQ=","value":[{"key":"YmF0","value":"QQ=="}]}]}]`), 0600)) // Import database. path := tempfile() @@ -26,15 +26,20 @@ func TestImport(t *testing.T) { db, err := bolt.Open(path, 0600) assert.NoError(t, err) db.View(func(tx *bolt.Tx) error { - b := tx.Bucket("widgets") + assert.NotNil(t, tx.Bucket([]byte("empty"))) + + b := tx.Bucket([]byte("widgets")) if assert.NotNil(t, b) { assert.Equal(t, []byte("0000"), b.Get([]byte("foo"))) assert.Equal(t, []byte(""), b.Get([]byte("bar"))) } - b = tx.Bucket("woojits") + b = tx.Bucket([]byte("woojits")) if assert.NotNil(t, b) { assert.Equal(t, []byte("XXXX"), b.Get([]byte("baz"))) + + b = b.Bucket([]byte("woojits/subbucket")) + assert.Equal(t, []byte("A"), b.Get([]byte("bat"))) } return nil |