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

@ -61,18 +61,20 @@ func setup(t *testing.T) (*store.Account, func()) {
mox.Context = ctxbg
mox.ConfigStaticPath = filepath.FromSlash("../testdata/queue/mox.conf")
mox.MustLoadConfig(true, false)
mox.Shutdown, mox.ShutdownCancel = context.WithCancel(ctxbg)
err := Init()
tcheck(t, err, "queue init")
err = mtastsdb.Init(false)
tcheck(t, err, "mtastsdb init")
err = tlsrptdb.Init()
tcheck(t, err, "tlsrptdb init")
switchStop := store.Switchboard()
acc, err := store.OpenAccount(log, "mjl", false)
tcheck(t, err, "open account")
err = acc.SetPassword(log, "testtest")
tcheck(t, err, "set password")
switchStop := store.Switchboard()
mox.Shutdown, mox.ShutdownCancel = context.WithCancel(ctxbg)
return acc, func() {
acc.Close()
acc.WaitClosed()