Files
storm/node_test.go
Bjørn Erik Pedersen 0754020e25 Add multi-bucket support
This commits adds a new Node type. A Node is in many was analogous
to a Bolt bucket, but with all of Storm's easy to use methods attached to it.

A new Storm can now be supplied with a Bucket root, where all the data will be
stored below. When more partitioning of your data is needed, new nodes can be created
with the From method.

Fixes #7
2016-04-14 13:27:11 +02:00

27 lines
573 B
Go

package storm
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNode(t *testing.T) {
dir, _ := ioutil.TempDir(os.TempDir(), "storm")
defer os.RemoveAll(dir)
db, _ := Open(filepath.Join(dir, "storm.db"), Root("a"))
defer db.Close()
n1 := db.From("b", "c")
assert.Equal(t, db, n1.s)
assert.NotEqual(t, db.root, n1)
assert.Equal(t, db.root.rootBucket, []string{"a"})
assert.Equal(t, []string{"b", "c"}, n1.rootBucket)
n2 := n1.From("d", "e")
assert.Equal(t, []string{"b", "c", "d", "e"}, n2.rootBucket)
}