Skip to content

Commit 1d21a88

Browse files
committed
file: support collections with "." in the name
1 parent c3501f2 commit 1d21a88

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (f *File) BuildCatalog() (*Catalog, error) {
7070
// process namespaces
7171
for name, ns := range f.Namespaces {
7272
// split name
73-
segments := strings.Split(name, ".")
73+
segments := strings.SplitN(name, ".", 2)
7474
if len(segments) != 2 {
7575
return nil, fmt.Errorf("invalid namespace name %q", name)
7676
}

file_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package lungo
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
8+
"github.com/256dpi/lungo/mongokit"
9+
)
10+
11+
func TestFile(t *testing.T) {
12+
catalog := NewCatalog()
13+
assert.NotNil(t, catalog)
14+
15+
catalog.Namespaces[Oplog] = mongokit.NewCollection(false)
16+
catalog.Namespaces[Handle{"test", "foo.bar"}] = mongokit.NewCollection(false)
17+
18+
file := BuildFile(catalog)
19+
assert.NotNil(t, file)
20+
21+
catalog2, err := file.BuildCatalog()
22+
assert.Nil(t, err)
23+
assert.NotNil(t, catalog2)
24+
}

0 commit comments

Comments
 (0)