Skip to content

Commit

Permalink
store/boltdb: Allow paths with no slash at the beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Pentecost committed May 5, 2017
1 parent 1d84310 commit 00745c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 4 additions & 2 deletions store/boltdb/boltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ func New(endpoints []string, options *store.Config) (store.Store, error) {
}

dir, _ := filepath.Split(endpoints[0])
if err = os.MkdirAll(dir, 0750); err != nil {
return nil, err
if dir != "" {
if err = os.MkdirAll(dir, 0750); err != nil {
return nil, err
}
}

if options.PersistConnection {
Expand Down
15 changes: 14 additions & 1 deletion store/boltdb/boltdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,24 @@ func TestConcurrentConnection(t *testing.T) {
_ = os.Remove("/tmp/__boltdbtest")
}

func TestBoldDBStore(t *testing.T) {
func TestBoltDBStore(t *testing.T) {
kv := makeBoltDBClient(t)

testutils.RunTestCommon(t, kv)
testutils.RunTestAtomic(t, kv)

_ = os.Remove("/tmp/not_exist_dir/__boltdbtest")
}

func TestRelativePathWithNoBeginningSlash(t *testing.T) {

_, err := libkv.NewStore(
store.BOLTDB,
[]string{"__boltdbtest"},
&store.Config{
Bucket: "boltDBTest",
},
)

assert.NoError(t, err)
}

0 comments on commit 00745c8

Please sign in to comment.