mirror of
https://github.com/mjl-/mox.git
synced 2025-07-14 02:54:37 +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:
@ -56,13 +56,13 @@ func TestAPI(t *testing.T) {
|
||||
mox.ConfigStaticPath = filepath.FromSlash("../testdata/webmail/mox.conf")
|
||||
mox.ConfigDynamicPath = filepath.FromSlash("../testdata/webmail/domains.conf")
|
||||
mox.MustLoadConfig(true, false)
|
||||
defer store.Switchboard()()
|
||||
err := store.Init(ctxbg)
|
||||
tcheck(t, err, "store init")
|
||||
defer func() {
|
||||
err := store.Close()
|
||||
tcheck(t, err, "store close")
|
||||
}()
|
||||
defer store.Switchboard()()
|
||||
|
||||
log := mlog.New("webmail", nil)
|
||||
err = mtastsdb.Init(false)
|
||||
|
@ -29,13 +29,13 @@ func TestView(t *testing.T) {
|
||||
mox.Context = ctxbg
|
||||
mox.ConfigStaticPath = filepath.FromSlash("../testdata/webmail/mox.conf")
|
||||
mox.MustLoadConfig(true, false)
|
||||
defer store.Switchboard()()
|
||||
err := store.Init(ctxbg)
|
||||
tcheck(t, err, "store init")
|
||||
defer func() {
|
||||
err := store.Close()
|
||||
tcheck(t, err, "store close")
|
||||
}()
|
||||
defer store.Switchboard()()
|
||||
|
||||
log := mlog.New("webmail", nil)
|
||||
acc, err := store.OpenAccount(log, "mjl", false)
|
||||
|
@ -308,13 +308,13 @@ func TestWebmail(t *testing.T) {
|
||||
mox.Context = ctxbg
|
||||
mox.ConfigStaticPath = filepath.FromSlash("../testdata/webmail/mox.conf")
|
||||
mox.MustLoadConfig(true, false)
|
||||
defer store.Switchboard()()
|
||||
err := store.Init(ctxbg)
|
||||
tcheck(t, err, "store init")
|
||||
defer func() {
|
||||
err := store.Close()
|
||||
tcheck(t, err, "store close")
|
||||
}()
|
||||
defer store.Switchboard()()
|
||||
|
||||
log := mlog.New("webmail", nil)
|
||||
acc, err := store.OpenAccount(pkglog, "mjl", false)
|
||||
@ -324,7 +324,7 @@ func TestWebmail(t *testing.T) {
|
||||
defer func() {
|
||||
err := acc.Close()
|
||||
pkglog.Check(err, "closing account")
|
||||
acc.CheckClosed()
|
||||
acc.WaitClosed()
|
||||
}()
|
||||
|
||||
api := Webmail{maxMessageSize: 1024 * 1024, cookiePath: "/webmail/"}
|
||||
|
Reference in New Issue
Block a user