Add roomserver tests (2/?) (#2445)

* Add invite table tests; move variable declarations

* Add Membership table tests

* Move variable declarations

* Add PrevEvents table tests

* Add Published table test

* Add Redactions tests
Fix bug in SQLite markRedactionValidatedSQL

* PR comments, better readability for invite tests
This commit is contained in:
Till 2022-05-10 14:41:12 +02:00 committed by GitHub
parent 1897e2f1c0
commit 6db08b2874
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 517 additions and 66 deletions

View file

@ -81,12 +81,12 @@ type inviteStatements struct {
updateInviteRetiredStmt *sql.Stmt
}
func createInvitesTable(db *sql.DB) error {
func CreateInvitesTable(db *sql.DB) error {
_, err := db.Exec(inviteSchema)
return err
}
func prepareInvitesTable(db *sql.DB) (tables.Invites, error) {
func PrepareInvitesTable(db *sql.DB) (tables.Invites, error) {
s := &inviteStatements{}
return s, sqlutil.StatementList{
@ -127,8 +127,8 @@ func (s *inviteStatements) UpdateInviteRetired(
defer internal.CloseAndLogIfError(ctx, rows, "updateInviteRetired: rows.close() failed")
var eventIDs []string
var inviteEventID string
for rows.Next() {
var inviteEventID string
if err = rows.Scan(&inviteEventID); err != nil {
return nil, err
}
@ -152,9 +152,9 @@ func (s *inviteStatements) SelectInviteActiveForUserInRoom(
defer internal.CloseAndLogIfError(ctx, rows, "selectInviteActiveForUserInRoom: rows.close() failed")
var result []types.EventStateKeyNID
var eventIDs []string
var inviteEventID string
var senderUserNID int64
for rows.Next() {
var inviteEventID string
var senderUserNID int64
if err := rows.Scan(&inviteEventID, &senderUserNID); err != nil {
return nil, nil, err
}