feat: complete IM P0 and P1 reliability work
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
//go:build mysql
|
||||
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type recordingGroupSchemaExecutor struct {
|
||||
statements []string
|
||||
}
|
||||
|
||||
func (e *recordingGroupSchemaExecutor) Exec(query string, _ ...any) (sql.Result, error) {
|
||||
e.statements = append(e.statements, query)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func TestEnsureIMGroupBusinessTablesUsesSelectedTenantDatabase(t *testing.T) {
|
||||
exec := &recordingGroupSchemaExecutor{}
|
||||
if err := ensureIMGroupBusinessTables(exec); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(exec.statements) != 12 {
|
||||
t.Fatalf("created %d group tables, want 12", len(exec.statements))
|
||||
}
|
||||
for _, statement := range exec.statements {
|
||||
if strings.Contains(strings.ToLower(statement), "tinode.") || strings.Contains(strings.ToLower(statement), "create database") {
|
||||
t.Fatalf("group schema must use the selected tenant database: %s", statement)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user