Skip to content

Commit

Permalink
accept unvalid driver and just return the default
Browse files Browse the repository at this point in the history
  • Loading branch information
sredxny committed May 31, 2023
1 parent 8451a35 commit 0084579
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
7 changes: 2 additions & 5 deletions persistent/storage.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package persistent

import (
"errors"

"github.com/TykTechnologies/storage/persistent/internal/driver/mongo"

"github.com/TykTechnologies/storage/persistent/internal/driver/mgo"
Expand All @@ -26,9 +24,8 @@ func NewPersistentStorage(opts *ClientOpts) (types.PersistentStorage, error) {
switch opts.Type {
case OfficialMongo:
return mongo.NewMongoDriver(&clientOpts)
case Mgo:
return mgo.NewMgoDriver(&clientOpts)
default:
return nil, errors.New("invalid driver")
//case MGO, or any unvalid
return mgo.NewMgoDriver(&clientOpts)
}
}
6 changes: 1 addition & 5 deletions persistent/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ func TestNewPersistentStorage(t *testing.T) {
Type: tc,
})

if tc == "unvalid" {
assert.Error(t, err)
} else {
assert.Nil(t, err)
}
assert.Nil(t, err)
})
}
}

0 comments on commit 0084579

Please sign in to comment.