Skip to content

Commit

Permalink
add dbType to DBIsAlive
Browse files Browse the repository at this point in the history
  • Loading branch information
hisham waleed karam committed Oct 14, 2018
1 parent 7b1e2d5 commit b1d94cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (manager *ManagerConfig) PublishGeoserverLayer(layer *GdalLayer) (ok bool,
//LayerToPostgis add Layer to Postgis
func (layer *GdalLayer) LayerToPostgis(targetSource *gdal.DataSource, manager *ManagerConfig, overwrite bool) (newLayer *GdalLayer, err error) {
connStr := manager.Datastore.PostgresConnectionString()
dbErr := DBIsAlive(connStr)
dbErr := DBIsAlive("postgres", connStr)
if dbErr != nil {
err = dbErr
return
Expand Down
4 changes: 2 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func GetGISFiles(root string) ([]string, error) {
}

//DBIsAlive check if database alive
func DBIsAlive(connectionStr string) (err error) {
db, dbErr := sql.Open("postgres", connectionStr)
func DBIsAlive(dbType string, connectionStr string) (err error) {
db, dbErr := sql.Open(dbType, connectionStr)
if dbErr != nil {
err = dbErr
return
Expand Down
6 changes: 3 additions & 3 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func TestGetGISFiles(t *testing.T) {
func TestDBIsAlive(t *testing.T) {
manager, _ := FromConfig("./testdata/test_config.yml")
connStr := manager.Datastore.PostgresConnectionString()
dbErr := DBIsAlive(connStr)
dbErr := DBIsAlive("postgres", connStr)
assert.Nil(t, dbErr)
connStr = "xxxxx"
err := DBIsAlive(connStr)
connStr = "mysql://"
err := DBIsAlive("mysql", connStr)
assert.NotNil(t, err)
}

0 comments on commit b1d94cd

Please sign in to comment.