In storage consistency checks, verify the junk filter has the expected word counts

Fix up a test or two. Simplify the XOR logic when we train the junk filter:
Only if junk or nonjunk is set, but not when both (or none are set). i.e. when
the values aren't the same.

Locking the account when we do consistency checks prevents spurious test
failures that may have been introduced in the previous commit.
This commit is contained in:
Mechiel Lukkien
2025-02-26 14:40:47 +01:00
parent aa85baf511
commit 394bdef39d
5 changed files with 128 additions and 31 deletions

View File

@ -6,8 +6,6 @@ import (
"strings"
"testing"
"github.com/mjl-/bstore"
"github.com/mjl-/mox/dns"
"github.com/mjl-/mox/smtp"
"github.com/mjl-/mox/smtpclient"
@ -279,10 +277,7 @@ test email
})
// Mark message as junk.
q := bstore.QueryDB[store.Message](ctxbg, ts.acc.DB)
n, err := q.UpdateFields(map[string]any{"Junk": true})
tcheck(t, err, "mark as junk")
tcompare(t, n, 1)
ts.xops.MessageFlagsAdd(ctxbg, pkglog, ts.acc, []int64{1}, []string{"$Junk"})
ts.run(func(client *smtpclient.Client) {
mailFrom := "mjl@mox.example"