Ensure txns are closed so we can wipe the db for other tests

This commit is contained in:
Kegan Dougal 2024-05-17 16:09:02 +01:00
parent 5028f93f83
commit af1f34861e
2 changed files with 6 additions and 1 deletions

View File

@ -151,6 +151,7 @@ func TestClearStuckInvites(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer tx.Rollback()
// users in room B (bob) and F (doris) should be reset.
tokens, err := tokensTable.TokenForEachDevice(tx)

View File

@ -1,11 +1,13 @@
package testutils
import (
"context"
"database/sql"
"fmt"
"os"
"os/exec"
"os/user"
"time"
)
var Quiet = false
@ -64,7 +66,9 @@ func PrepareDBConnectionString() (connStr string) {
if err != nil {
panic(err)
}
_, err = db.Exec(`DROP SCHEMA public CASCADE;
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
_, err = db.ExecContext(ctx, `DROP SCHEMA public CASCADE;
CREATE SCHEMA public;`)
if err != nil {
panic(err)