From 10fed5f74d44caad8f777a38db735ebb7fb3e65b Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Fri, 11 Apr 2014 14:59:46 -0600 Subject: Upgrade import/export to use nested buckets. --- cmd/bolt/import_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'cmd/bolt/import_test.go') 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 -- cgit v1.2.3