[GH-13931] Return error in parseDSN func #13931 (#13947)

Automatic Merge
This commit is contained in:
upwell
2020-03-04 00:42:17 +08:00
committed by GitHub
parent 25e8eb9eef
commit 058f235050
2 changed files with 4 additions and 1 deletions

View File

@@ -139,7 +139,7 @@ func parseDSN(dsn string) (string, string, error) {
// Treat the DSN as the URL that it is.
s := strings.SplitN(dsn, "://", 2)
if len(s) != 2 {
errors.New("failed to parse DSN as URL")
return "", "", errors.New("failed to parse DSN as URL")
}
scheme := s[0]

View File

@@ -155,6 +155,9 @@ func TestDatabaseStoreNew(t *testing.T) {
t.Run("invalid url", func(t *testing.T) {
_, err := config.NewDatabaseStore("")
require.Error(t, err)
_, err = config.NewDatabaseStore("mysql")
require.Error(t, err)
})
t.Run("unsupported scheme", func(t *testing.T) {