This commit is contained in:
Till Faelligen 2022-08-12 08:04:25 +02:00
parent 51372cbb8f
commit 023ab1a15c
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -4,18 +4,19 @@ import (
"context" "context"
"testing" "testing"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/setup/config" "github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/dendrite/test" "github.com/matrix-org/dendrite/test"
"github.com/matrix-org/dendrite/userapi/storage/postgres" "github.com/matrix-org/dendrite/userapi/storage/postgres"
"github.com/matrix-org/dendrite/userapi/storage/sqlite3" "github.com/matrix-org/dendrite/userapi/storage/sqlite3"
"github.com/matrix-org/dendrite/userapi/storage/tables" "github.com/matrix-org/dendrite/userapi/storage/tables"
"github.com/matrix-org/gomatrixserverlib"
) )
const serverNotice = "notice" const serverNotice = "notice"
func mustCreateProfileTable(t *testing.T, dbType test.DBType) (tab tables.ProfileTable, close func()) { func mustCreateProfileTable(t *testing.T, dbType test.DBType, serverName gomatrixserverlib.ServerName) (tab tables.ProfileTable, close func()) {
var connStr string var connStr string
connStr, close = test.PrepareDBConnectionString(t, dbType) connStr, close = test.PrepareDBConnectionString(t, dbType)
db, err := sqlutil.Open(&config.DatabaseOptions{ db, err := sqlutil.Open(&config.DatabaseOptions{
@ -26,9 +27,9 @@ func mustCreateProfileTable(t *testing.T, dbType test.DBType) (tab tables.Profil
} }
switch dbType { switch dbType {
case test.DBTypePostgres: case test.DBTypePostgres:
tab, err = postgres.NewPostgresProfilesTable(db, serverNotice) tab, err = postgres.NewPostgresProfilesTable(db, serverNotice, serverName)
case test.DBTypeSQLite: case test.DBTypeSQLite:
tab, err = sqlite3.NewSQLiteProfilesTable(db, serverNotice) tab, err = sqlite3.NewSQLiteProfilesTable(db, serverNotice, serverName)
} }
if err != nil { if err != nil {
t.Fatalf("failed to create profiles table: %v", err) t.Fatalf("failed to create profiles table: %v", err)
@ -50,7 +51,7 @@ func TestProfileTable(t *testing.T) {
displayName := "newDisplayName" displayName := "newDisplayName"
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
tab, close := mustCreateProfileTable(t, dbType) tab, close := mustCreateProfileTable(t, dbType, serverName1)
defer close() defer close()
// Create serverNotice user // Create serverNotice user
if err := tab.InsertProfile(ctx, nil, serverNotice, serverName1); err != nil { if err := tab.InsertProfile(ctx, nil, serverNotice, serverName1); err != nil {