mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 08:23:48 +03:00
in more tests, after closing accounts, check the last reference is indeed gone
This commit is contained in:
parent
afc47c8108
commit
abd098e8c0
13 changed files with 30 additions and 5 deletions
|
@ -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")
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -38,6 +38,7 @@ func TestMailbox(t *testing.T) {
|
|||
defer func() {
|
||||
err = acc.Close()
|
||||
tcheck(t, err, "closing account")
|
||||
acc.CheckClosed()
|
||||
}()
|
||||
defer Switchboard()()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -97,6 +97,7 @@ func TestAccount(t *testing.T) {
|
|||
defer func() {
|
||||
err = acc.Close()
|
||||
tcheck(t, err, "closing account")
|
||||
acc.CheckClosed()
|
||||
}()
|
||||
defer store.Switchboard()()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: "/"}
|
||||
|
|
|
@ -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/"}
|
||||
|
|
Loading…
Reference in a new issue