Skip to content

Commit

Permalink
make getBackendDBUri private
Browse files Browse the repository at this point in the history
  • Loading branch information
dm-2 committed Jan 25, 2023
1 parent f8eb180 commit 14d9dfa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/group/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewMySQLBackend(throttler *throttle.Throttler) (*MySQLBackend, error) {
if config.Settings().BackendMySQLHost == "" {
return nil, nil
}
dbUri := GetBackendDBUri()
dbUri := getBackendDBUri()
db, _, err := sqlutils.GetDB(dbUri)
if err != nil {
return nil, err
Expand Down Expand Up @@ -107,7 +107,7 @@ func NewMySQLBackend(throttler *throttle.Throttler) (*MySQLBackend, error) {
}

// helper function to get the DB URI
func GetBackendDBUri() string {
func getBackendDBUri() string {
dsnCharsetCollation := "charset=utf8mb4,utf8,latin1"
if config.Settings().BackendMySQLCollation != "" {
// Set collation instead of charset, if BackendMySQLCollation is specified
Expand Down
4 changes: 2 additions & 2 deletions pkg/group/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func TestGetBackendDBUri(t *testing.T) {
config.Settings().BackendMySQLSchema = "test_database"

// test default (charset)
dbUri := GetBackendDBUri()
dbUri := getBackendDBUri()
test.S(t).ExpectEquals(dbUri, "gromit:penguin@tcp(myhost:3306)/test_database?interpolateParams=true&charset=utf8mb4,utf8,latin1&timeout=500ms")

// test setting collation
config.Settings().BackendMySQLCollation = "utf8mb4_unicode_ci"
dbUri = GetBackendDBUri()
dbUri = getBackendDBUri()
test.S(t).ExpectEquals(dbUri, "gromit:penguin@tcp(myhost:3306)/test_database?interpolateParams=true&collation=utf8mb4_unicode_ci&timeout=500ms")
}

0 comments on commit 14d9dfa

Please sign in to comment.