diff --git a/ctl_test.go b/ctl_test.go index 517e653..aaa01bb 100644 --- a/ctl_test.go +++ b/ctl_test.go @@ -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") diff --git a/imapserver/fuzz_test.go b/imapserver/fuzz_test.go index fe57563..94ffced 100644 --- a/imapserver/fuzz_test.go +++ b/imapserver/fuzz_test.go @@ -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) diff --git a/imapserver/server_test.go b/imapserver/server_test.go index 6fc290e..a0564b2 100644 --- a/imapserver/server_test.go +++ b/imapserver/server_test.go @@ -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() diff --git a/smtpserver/fuzz_test.go b/smtpserver/fuzz_test.go index d276d72..ef5fc6b 100644 --- a/smtpserver/fuzz_test.go +++ b/smtpserver/fuzz_test.go @@ -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) diff --git a/smtpserver/server_test.go b/smtpserver/server_test.go index ae3b33d..4aa6a3d 100644 --- a/smtpserver/server_test.go +++ b/smtpserver/server_test.go @@ -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) diff --git a/store/account_test.go b/store/account_test.go index 77a8e64..732c6d4 100644 --- a/store/account_test.go +++ b/store/account_test.go @@ -38,6 +38,7 @@ func TestMailbox(t *testing.T) { defer func() { err = acc.Close() tcheck(t, err, "closing account") + acc.CheckClosed() }() defer Switchboard()() diff --git a/store/export_test.go b/store/export_test.go index e2abad5..3afb3d1 100644 --- a/store/export_test.go +++ b/store/export_test.go @@ -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) diff --git a/store/threads_test.go b/store/threads_test.go index fa63e5d..a273f6f 100644 --- a/store/threads_test.go +++ b/store/threads_test.go @@ -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. diff --git a/webaccount/account_test.go b/webaccount/account_test.go index f011bce..4d8a01a 100644 --- a/webaccount/account_test.go +++ b/webaccount/account_test.go @@ -97,6 +97,7 @@ func TestAccount(t *testing.T) { defer func() { err = acc.Close() tcheck(t, err, "closing account") + acc.CheckClosed() }() defer store.Switchboard()() diff --git a/webapisrv/server_test.go b/webapisrv/server_test.go index 8e7ab36..5fb3886 100644 --- a/webapisrv/server_test.go +++ b/webapisrv/server_test.go @@ -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) diff --git a/webmail/api_test.go b/webmail/api_test.go index 7d3f902..7919514 100644 --- a/webmail/api_test.go +++ b/webmail/api_test.go @@ -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 diff --git a/webmail/view_test.go b/webmail/view_test.go index f8a3950..743e5d6 100644 --- a/webmail/view_test.go +++ b/webmail/view_test.go @@ -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: "/"} diff --git a/webmail/webmail_test.go b/webmail/webmail_test.go index 90e032d..f70bce3 100644 --- a/webmail/webmail_test.go +++ b/webmail/webmail_test.go @@ -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/"}