mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
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:
@ -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()
|
||||
|
Reference in New Issue
Block a user