func TestInsert(t *testing.T) {
	bx := NewTestDB()
	defer bx.Close()

	paths, err := bx.New([]byte("paths"))

	// k, v pairs to put in `paths` bucket
	items := []struct {
		Key, Value []byte
	}{
		{[]byte("foo/"), []byte("foo")},
		{[]byte("foo/bar/"), []byte("bar")},
		{[]byte("foo/bar/baz/"), []byte("baz")},
		{[]byte("food/"), []byte("")},
		{[]byte("good/"), []byte("")},
		{[]byte("goo/"), []byte("")},
	}

	err = paths.Insert(items)
	if err != nil {
		t.Error(err.Error())
	}

	gotItems, err := paths.Items()
	if err != nil {
		t.Error(err.Error())
	}

	// expected k/v mapping
	expected := map[string][]byte{
		"foo/":         []byte("foo"),
		"foo/bar/":     []byte("bar"),
		"foo/bar/baz/": []byte("baz"),
		"food/":        []byte(""),
		"good/":        []byte(""),
		"goo/":         []byte(""),
	}

	for _, item := range gotItems {
		want := expected[string(item.Key)]
		if !bytes.Equal(item.Value, want) {
			t.Errorf("got %v, want %v", item.Value, want)
		}
	}
}
// Ensure we can insert items into a bucket and get them back out.
Ensure we can insert items into a bucket and get them back out.
// Ensure we can insert items into a bucket and get them back out .
func TestInsert(t *testing.T) {
	bx := NewTestDB()
	defer bx.Close()
	paths, err := bx.New([]byte("paths"))
	items := []struct {
		Key, Value []byte
	}{
		{[]byte("foo/"), []byte("foo")},
		{[]byte("foo/bar/"), []byte("bar")},
		{[]byte("foo/bar/baz/"), []byte("baz")},
		{[]byte("food/"), []byte("")},
		{[]byte("good/"), []byte("")},
		{[]byte("goo/"), []byte("")},
	}
	err = paths.Insert(items)
	if err != nil {
		t.Error(err.Error())
	}
	gotItems, err := paths.Items()
	if err != nil {
		t.Error(err.Error())
	}
	expected := map[string][]byte{
		"foo/":         []byte("foo"),
		"foo/bar/":     []byte("bar"),
		"foo/bar/baz/": []byte("baz"),
		"food/":        []byte(""),
		"good/":        []byte(""),
		"goo/":         []byte(""),
	}
	for _, item := range gotItems {
		want := expected[string(item.Key)]
		if !bytes.Equal(item.Value, want) {
			t.Errorf("got %v, want %v", item.Value, want)
		}
	}
}
func TestInsert ( t * testing . T ) { bx := NewTestDB ( ) defer bx . Close ( ) paths , err := bx . New ( [ ] byte ( " " ) ) items := [ ] struct { Key , Value [ ] byte } { { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , } err = paths . Insert ( items ) if err != nil { t . Error ( err . Error ( ) ) } gotItems , err := paths . Items ( ) if err != nil { t . Error ( err . Error ( ) ) } expected := map [ string ] [ ] byte { " " : [ ] byte ( " " ) , " " : [ ] byte ( " " ) , " " : [ ] byte ( " " ) , " " : [ ] byte ( " " ) , " " : [ ] byte ( " " ) , " " : [ ] byte ( " " ) , } for _ , item := range gotItems { want := expected [ string ( item . Key ) ] if ! bytes . Equal ( item . Value , want ) { t . Errorf ( " " , item . Value , want ) } } }
Ensure we can insert items into a bucket and get them back out.
Ensure we can insert items into a bucket and get them back out .
// k, v pairs to put in `paths` bucket // expected k/v mapping