mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-26 06:58:27 +00:00
Fix tests for x86 (#3214)
This commit is contained in:
parent
1853f58cb4
commit
3d02c81031
7 changed files with 7 additions and 7 deletions
|
@ -58,7 +58,7 @@ type mockDB struct {
|
||||||
roomID string
|
roomID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *mockDB) SelectMembershipForUser(ctx context.Context, roomID string, userID string, pos int64) (string, int, error) {
|
func (s *mockDB) SelectMembershipForUser(ctx context.Context, roomID string, userID string, pos int64) (string, int64, error) {
|
||||||
if roomID == s.roomID {
|
if roomID == s.roomID {
|
||||||
membership, ok := s.currentMembership[userID]
|
membership, ok := s.currentMembership[userID]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
@ -107,7 +107,7 @@ type DatabaseTransaction interface {
|
||||||
// SelectMembershipForUser returns the membership of the user before and including the given position. If no membership can be found
|
// SelectMembershipForUser returns the membership of the user before and including the given position. If no membership can be found
|
||||||
// returns "leave", the topological position and no error. If an error occurs, other than sql.ErrNoRows, returns that and an empty
|
// returns "leave", the topological position and no error. If an error occurs, other than sql.ErrNoRows, returns that and an empty
|
||||||
// string as the membership.
|
// string as the membership.
|
||||||
SelectMembershipForUser(ctx context.Context, roomID, userID string, pos int64) (membership string, topologicalPos int, err error)
|
SelectMembershipForUser(ctx context.Context, roomID, userID string, pos int64) (membership string, topologicalPos int64, err error)
|
||||||
// getUserUnreadNotificationCountsForRooms returns the unread notifications for the given rooms
|
// getUserUnreadNotificationCountsForRooms returns the unread notifications for the given rooms
|
||||||
GetUserUnreadNotificationCountsForRooms(ctx context.Context, userID string, roomIDs map[string]string) (map[string]*eventutil.NotificationData, error)
|
GetUserUnreadNotificationCountsForRooms(ctx context.Context, userID string, roomIDs map[string]string) (map[string]*eventutil.NotificationData, error)
|
||||||
GetPresences(ctx context.Context, userID []string) ([]*types.PresenceInternal, error)
|
GetPresences(ctx context.Context, userID []string) ([]*types.PresenceInternal, error)
|
||||||
|
|
|
@ -131,7 +131,7 @@ func (s *membershipsStatements) SelectMembershipCount(
|
||||||
// string as the membership.
|
// string as the membership.
|
||||||
func (s *membershipsStatements) SelectMembershipForUser(
|
func (s *membershipsStatements) SelectMembershipForUser(
|
||||||
ctx context.Context, txn *sql.Tx, roomID, userID string, pos int64,
|
ctx context.Context, txn *sql.Tx, roomID, userID string, pos int64,
|
||||||
) (membership string, topologyPos int, err error) {
|
) (membership string, topologyPos int64, err error) {
|
||||||
stmt := sqlutil.TxStmt(txn, s.selectMembershipForUserStmt)
|
stmt := sqlutil.TxStmt(txn, s.selectMembershipForUserStmt)
|
||||||
err = stmt.QueryRowContext(ctx, roomID, userID, pos).Scan(&membership, &topologyPos)
|
err = stmt.QueryRowContext(ctx, roomID, userID, pos).Scan(&membership, &topologyPos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -583,7 +583,7 @@ func (d *Database) GetPresences(ctx context.Context, userIDs []string) ([]*types
|
||||||
return d.Presence.GetPresenceForUsers(ctx, nil, userIDs)
|
return d.Presence.GetPresenceForUsers(ctx, nil, userIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Database) SelectMembershipForUser(ctx context.Context, roomID, userID string, pos int64) (membership string, topologicalPos int, err error) {
|
func (d *Database) SelectMembershipForUser(ctx context.Context, roomID, userID string, pos int64) (membership string, topologicalPos int64, err error) {
|
||||||
return d.Memberships.SelectMembershipForUser(ctx, nil, roomID, userID, pos)
|
return d.Memberships.SelectMembershipForUser(ctx, nil, roomID, userID, pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ func (s *membershipsStatements) SelectMembershipCount(
|
||||||
// string as the membership.
|
// string as the membership.
|
||||||
func (s *membershipsStatements) SelectMembershipForUser(
|
func (s *membershipsStatements) SelectMembershipForUser(
|
||||||
ctx context.Context, txn *sql.Tx, roomID, userID string, pos int64,
|
ctx context.Context, txn *sql.Tx, roomID, userID string, pos int64,
|
||||||
) (membership string, topologyPos int, err error) {
|
) (membership string, topologyPos int64, err error) {
|
||||||
stmt := sqlutil.TxStmt(txn, s.selectMembershipForUserStmt)
|
stmt := sqlutil.TxStmt(txn, s.selectMembershipForUserStmt)
|
||||||
err = stmt.QueryRowContext(ctx, roomID, userID, pos).Scan(&membership, &topologyPos)
|
err = stmt.QueryRowContext(ctx, roomID, userID, pos).Scan(&membership, &topologyPos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -194,7 +194,7 @@ type Receipts interface {
|
||||||
type Memberships interface {
|
type Memberships interface {
|
||||||
UpsertMembership(ctx context.Context, txn *sql.Tx, event *rstypes.HeaderedEvent, streamPos, topologicalPos types.StreamPosition) error
|
UpsertMembership(ctx context.Context, txn *sql.Tx, event *rstypes.HeaderedEvent, streamPos, topologicalPos types.StreamPosition) error
|
||||||
SelectMembershipCount(ctx context.Context, txn *sql.Tx, roomID, membership string, pos types.StreamPosition) (count int, err error)
|
SelectMembershipCount(ctx context.Context, txn *sql.Tx, roomID, membership string, pos types.StreamPosition) (count int, err error)
|
||||||
SelectMembershipForUser(ctx context.Context, txn *sql.Tx, roomID, userID string, pos int64) (membership string, topologicalPos int, err error)
|
SelectMembershipForUser(ctx context.Context, txn *sql.Tx, roomID, userID string, pos int64) (membership string, topologicalPos int64, err error)
|
||||||
PurgeMemberships(ctx context.Context, txn *sql.Tx, roomID string) error
|
PurgeMemberships(ctx context.Context, txn *sql.Tx, roomID string) error
|
||||||
SelectMemberships(
|
SelectMemberships(
|
||||||
ctx context.Context, txn *sql.Tx,
|
ctx context.Context, txn *sql.Tx,
|
||||||
|
|
|
@ -124,7 +124,7 @@ func testUpsert(t *testing.T, ctx context.Context, table tables.Memberships, mem
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to select membership: %s", err)
|
t.Fatalf("failed to select membership: %s", err)
|
||||||
}
|
}
|
||||||
expectedPos := 1
|
var expectedPos int64 = 1
|
||||||
if pos != expectedPos {
|
if pos != expectedPos {
|
||||||
t.Fatalf("expected pos to be %d, got %d", expectedPos, pos)
|
t.Fatalf("expected pos to be %d, got %d", expectedPos, pos)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue