1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2025-07-01 03:30:21 +02:00
aerc/worker/imap/search_test.go
Simon Martin 03061fe21f imap: fix processing of search criteria end date
This patch fixes a copy/paste error in translateSearch that was leading
to the types.SearchCriteria's StartDate to be mapped to both SentSince
and SentBefore in the imap.SearchCriteria, and the actual EndDate to be
ignored.

Fixes: 8464b37385 ("search: use a common api for all workers")
Signed-off-by: Simon Martin <simon@nasilyan.com>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-03-09 00:40:30 +01:00

45 lines
896 B
Go

package imap
import (
"testing"
"time"
"git.sr.ht/~rjarry/aerc/worker/types"
)
func Test_translateSearch_ByDate(t *testing.T) {
tests := []struct {
name string
StartDate time.Time
EndDate time.Time
}{
{
name: "Only StartDate",
StartDate: time.Now(),
},
{
name: "Only EndDate",
EndDate: time.Now(),
},
{
name: "Both dates",
StartDate: time.Now(),
EndDate: time.Now(),
},
}
for _, test := range tests {
crit := &types.SearchCriteria{
StartDate: test.StartDate,
EndDate: test.EndDate,
}
sc := translateSearch(crit)
if sc.SentSince != test.StartDate {
t.Errorf("test '%s' failed: got: '%s', but wanted: '%s'",
test.name, sc.SentSince, test.StartDate)
}
if sc.SentBefore != test.EndDate {
t.Errorf("test '%s' failed: got: '%s', but wanted: '%s'",
test.name, sc.SentBefore, test.EndDate)
}
}
}