refactor: retire legacy tinode database routing
This commit is contained in:
@@ -43,7 +43,7 @@ const (
|
||||
adapterName = "mongodb"
|
||||
|
||||
defaultHost = "localhost:27017"
|
||||
defaultDatabase = "tinode"
|
||||
defaultDatabase = "meeting_im"
|
||||
|
||||
defaultMaxResults = 1024
|
||||
// This is capped by the Session's send queue limit (128).
|
||||
|
||||
@@ -248,6 +248,9 @@ func (a *adapter) Open(jsonconfig json.RawMessage) error {
|
||||
if a.dbName == "" {
|
||||
a.dbName = defaultDatabase
|
||||
}
|
||||
if strings.EqualFold(strings.TrimSpace(a.dbName), "tinode") {
|
||||
return errors.New("mysql database tinode is deprecated; use meeting_im")
|
||||
}
|
||||
config.Config.DBName = a.dbName
|
||||
a.baseConfig = &config
|
||||
a.tenantDBRouting = config.TenantDBRouting
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
ms "github.com/go-sql-driver/mysql"
|
||||
@@ -17,17 +19,17 @@ func TestNormalizeMySQLDSN(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "go driver dsn",
|
||||
dsn: "root:secret@tcp(127.0.0.1:3306)/tinode?parseTime=true",
|
||||
dsn: "root:secret@tcp(127.0.0.1:3306)/meeting_im?parseTime=true",
|
||||
user: "root",
|
||||
},
|
||||
{
|
||||
name: "url scheme dsn",
|
||||
dsn: "mysql://root:secret@tcp(127.0.0.1:3306)/tinode?parseTime=true",
|
||||
dsn: "mysql://root:secret@tcp(127.0.0.1:3306)/meeting_im?parseTime=true",
|
||||
user: "root",
|
||||
},
|
||||
{
|
||||
name: "legacy scheme dsn",
|
||||
dsn: "mysql:root:secret@tcp(127.0.0.1:3306)/tinode?parseTime=true",
|
||||
dsn: "mysql:root:secret@tcp(127.0.0.1:3306)/meeting_im?parseTime=true",
|
||||
user: "root",
|
||||
},
|
||||
}
|
||||
@@ -43,3 +45,13 @@ func TestNormalizeMySQLDSN(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenRejectsDeprecatedTinodeDatabase(t *testing.T) {
|
||||
config := json.RawMessage(`{"dsn":"mysql://root:secret@tcp(127.0.0.1:3306)/tinode?parseTime=true"}`)
|
||||
adp := &adapter{}
|
||||
|
||||
err := adp.Open(config)
|
||||
if err == nil || !strings.Contains(err.Error(), "tinode is deprecated") {
|
||||
t.Fatalf("Open() error = %v, want deprecated database error", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ const (
|
||||
adapterName = "rethinkdb"
|
||||
|
||||
defaultHost = "localhost:28015"
|
||||
defaultDatabase = "tinode"
|
||||
defaultDatabase = "meeting_im"
|
||||
|
||||
defaultMaxResults = 1024
|
||||
// This is capped by the Session's send queue limit (128).
|
||||
|
||||
Reference in New Issue
Block a user