In tests, make initializing store/, its switchboard and an account more consistent.

Initialize store and switchboard first, then open account, and close in reverse
order.

Replace all "CheckClosed" calls with "WaitClosed", future changings will keep
an account reference open for a bit after the last regular close, so we can't
know that an account should be closed during tests.

Remove one parameter from the (still too long) "start test server" function in
imapserver testing code.
This commit is contained in:
Mechiel Lukkien
2025-03-15 11:15:23 +01:00
parent eadbda027c
commit c4255a96f8
16 changed files with 69 additions and 62 deletions

View File

@ -19,14 +19,15 @@ func TestThreadingUpgrade(t *testing.T) {
os.RemoveAll("../testdata/store/data")
mox.ConfigStaticPath = filepath.FromSlash("../testdata/store/mox.conf")
mox.MustLoadConfig(true, false)
defer Switchboard()()
acc, err := OpenAccount(log, "mjl", true)
tcheck(t, err, "open account")
defer func() {
err = acc.Close()
tcheck(t, err, "closing account")
acc.CheckClosed()
acc.WaitClosed()
}()
defer Switchboard()()
// New account already has threading. Add some messages, check the threading.
deliver := func(recv time.Time, s string, expThreadID int64) Message {
@ -120,7 +121,7 @@ func TestThreadingUpgrade(t *testing.T) {
dbpath := acc.DBPath
err = acc.Close()
tcheck(t, err, "close account")
acc.CheckClosed()
acc.WaitClosed()
// 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.