in more tests, after closing accounts, check the last reference is indeed gone

This commit is contained in:
Mechiel Lukkien 2024-04-16 17:33:54 +02:00
parent afc47c8108
commit abd098e8c0
No known key found for this signature in database
13 changed files with 30 additions and 5 deletions

View file

@ -327,7 +327,10 @@ func TestCtl(t *testing.T) {
testctl(func(ctl *ctl) {
acc, err := store.OpenAccount(ctl.log, "mjl")
tcheck(t, err, "open account")
defer acc.Close()
defer func() {
acc.Close()
acc.CheckClosed()
}()
content := []byte("Subject: hi\r\n\r\nbody\r\n")

View file

@ -69,7 +69,10 @@ func FuzzServer(f *testing.F) {
if err != nil {
f.Fatalf("open account: %v", err)
}
defer acc.Close()
defer func() {
acc.Close()
acc.CheckClosed()
}()
err = acc.SetPassword(log, password0)
if err != nil {
f.Fatalf("set password: %v", err)

View file

@ -310,6 +310,7 @@ func (tc *testconn) close() {
}
err := tc.account.Close()
tc.check(err, "close account")
// no account.CheckClosed(), the tests open accounts multiple times.
tc.account = nil
tc.client.Close()
tc.serverConn.Close()

View file

@ -41,7 +41,10 @@ func FuzzServer(f *testing.F) {
if err != nil {
f.Fatalf("open account: %v", err)
}
defer acc.Close()
defer func() {
acc.Close()
acc.CheckClosed()
}()
err = acc.SetPassword(log, "testtest")
if err != nil {
f.Fatalf("set password: %v", err)

View file

@ -139,6 +139,7 @@ func (ts *testserver) close() {
ts.switchStop()
err := ts.acc.Close()
tcheck(ts.t, err, "closing account")
ts.acc.CheckClosed()
ts.acc = nil
}
@ -1367,7 +1368,10 @@ func TestCatchall(t *testing.T) {
acc, err := store.OpenAccount(pkglog, "catchall")
tcheck(t, err, "open account")
defer acc.Close()
defer func() {
acc.Close()
acc.CheckClosed()
}()
n, err = bstore.QueryDB[store.Message](ctxbg, acc.DB).Count()
tcheck(t, err, "checking delivered messages to catchall account")
tcompare(t, n, 1)

View file

@ -38,6 +38,7 @@ func TestMailbox(t *testing.T) {
defer func() {
err = acc.Close()
tcheck(t, err, "closing account")
acc.CheckClosed()
}()
defer Switchboard()()

View file

@ -24,7 +24,10 @@ func TestExport(t *testing.T) {
mox.MustLoadConfig(true, false)
acc, err := OpenAccount(pkglog, "mjl")
tcheck(t, err, "open account")
defer acc.Close()
defer func() {
acc.Close()
acc.CheckClosed()
}()
defer Switchboard()()
log := mlog.New("export", nil)

View file

@ -24,6 +24,7 @@ func TestThreadingUpgrade(t *testing.T) {
defer func() {
err = acc.Close()
tcheck(t, err, "closing account")
acc.CheckClosed()
}()
defer Switchboard()()
@ -116,6 +117,7 @@ func TestThreadingUpgrade(t *testing.T) {
dbpath := acc.DBPath
err = acc.Close()
tcheck(t, err, "close account")
acc.CheckClosed()
// Now clear the threading upgrade, and the threading fields and close the account.
// We open the database file directly, so we don't trigger the consistency checker.

View file

@ -97,6 +97,7 @@ func TestAccount(t *testing.T) {
defer func() {
err = acc.Close()
tcheck(t, err, "closing account")
acc.CheckClosed()
}()
defer store.Switchboard()()

View file

@ -76,6 +76,7 @@ func TestServer(t *testing.T) {
defer func() {
err := acc.Close()
log.Check(err, "closing account")
acc.CheckClosed()
}()
s := NewServer(100*1024, "/webapi/", false).(server)

View file

@ -66,6 +66,7 @@ func TestAPI(t *testing.T) {
defer func() {
err := acc.Close()
pkglog.Check(err, "closing account")
acc.CheckClosed()
}()
var zerom store.Message

View file

@ -39,6 +39,7 @@ func TestView(t *testing.T) {
defer func() {
err := acc.Close()
pkglog.Check(err, "closing account")
acc.CheckClosed()
}()
api := Webmail{maxMessageSize: 1024 * 1024, cookiePath: "/"}

View file

@ -301,6 +301,7 @@ func TestWebmail(t *testing.T) {
defer func() {
err := acc.Close()
pkglog.Check(err, "closing account")
acc.CheckClosed()
}()
api := Webmail{maxMessageSize: 1024 * 1024, cookiePath: "/webmail/"}