Debugging unit tests..

This commit is contained in:
Till Faelligen 2022-05-04 18:38:43 +02:00
parent 94ed2d3689
commit 10dc02f1ea
4 changed files with 7 additions and 0 deletions

View file

@ -259,6 +259,7 @@ func (b *BaseDendrite) Close() error {
func (b *BaseDendrite) DatabaseConnection(dbProperties *config.DatabaseOptions, writer sqlutil.Writer) (*sql.DB, sqlutil.Writer, error) { func (b *BaseDendrite) DatabaseConnection(dbProperties *config.DatabaseOptions, writer sqlutil.Writer) (*sql.DB, sqlutil.Writer, error) {
if dbProperties.ConnectionString != "" || b == nil { if dbProperties.ConnectionString != "" || b == nil {
// Open a new database connection using the supplied config. // Open a new database connection using the supplied config.
logrus.Infof("Open a new database connection using the supplied config.: %+v", dbProperties.ConnectionString)
db, err := sqlutil.Open(dbProperties, writer) db, err := sqlutil.Open(dbProperties, writer)
return db, writer, err return db, writer, err
} }

View file

@ -27,6 +27,7 @@ import (
"time" "time"
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"github.com/matrix-org/dendrite/clientapi/auth/authtypes" "github.com/matrix-org/dendrite/clientapi/auth/authtypes"
@ -159,6 +160,7 @@ func (d *Database) createAccount(
} }
} }
if account, err = d.Accounts.InsertAccount(ctx, txn, localpart, hash, appserviceID, policyVersion, accountType); err != nil { if account, err = d.Accounts.InsertAccount(ctx, txn, localpart, hash, appserviceID, policyVersion, accountType); err != nil {
logrus.WithError(err).Error("d.Accounts.InsertAccount error")
return nil, sqlutil.ErrUserExists return nil, sqlutil.ErrUserExists
} }
if err = d.Profiles.InsertProfile(ctx, txn, localpart); err != nil { if err = d.Profiles.InsertProfile(ctx, txn, localpart); err != nil {

View file

@ -19,6 +19,7 @@ import (
"time" "time"
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
"github.com/sirupsen/logrus"
"github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/setup/base" "github.com/matrix-org/dendrite/setup/base"
@ -44,6 +45,7 @@ func NewDatabase(base *base.BaseDendrite, dbProperties *config.DatabaseOptions,
// preparing statements for columns that don't exist yet // preparing statements for columns that don't exist yet
return nil, err return nil, err
} }
logrus.Info("created account_accounts table")
deltas.LoadIsActive(m) deltas.LoadIsActive(m)
//deltas.LoadLastSeenTSIP(m) //deltas.LoadLastSeenTSIP(m)
deltas.LoadAddAccountType(m) deltas.LoadAddAccountType(m)
@ -60,6 +62,7 @@ func NewDatabase(base *base.BaseDendrite, dbProperties *config.DatabaseOptions,
if err != nil { if err != nil {
return nil, fmt.Errorf("NewSQLiteAccountsTable: %w", err) return nil, fmt.Errorf("NewSQLiteAccountsTable: %w", err)
} }
logrus.Info("prepared statements for accounts table")
devicesTable, err := NewSQLiteDevicesTable(db, serverName) devicesTable, err := NewSQLiteDevicesTable(db, serverName)
if err != nil { if err != nil {
return nil, fmt.Errorf("NewSQLiteDevicesTable: %w", err) return nil, fmt.Errorf("NewSQLiteDevicesTable: %w", err)

View file

@ -73,6 +73,7 @@ func TestQueryProfile(t *testing.T) {
aliceAvatarURL := "mxc://example.com/alice" aliceAvatarURL := "mxc://example.com/alice"
aliceDisplayName := "Alice" aliceDisplayName := "Alice"
userAPI, accountDB := MustMakeInternalAPI(t, apiTestOpts{}) userAPI, accountDB := MustMakeInternalAPI(t, apiTestOpts{})
time.Sleep(time.Second)
_, err := accountDB.CreateAccount(context.TODO(), "alice", "foobar", "", "", api.AccountTypeUser) _, err := accountDB.CreateAccount(context.TODO(), "alice", "foobar", "", "", api.AccountTypeUser)
if err != nil { if err != nil {
t.Fatalf("failed to make account: %s", err) t.Fatalf("failed to make account: %s", err)