Skip to content

Commit ba82060

Browse files
committed
imapclient: add basic ESEARCH test
1 parent a2fdac2 commit ba82060

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

imapclient/search_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package imapclient_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/emersion/go-imap/v2"
7+
)
8+
9+
func TestESearch(t *testing.T) {
10+
client, server := newClientServerPair(t, imap.ConnStateSelected)
11+
defer client.Close()
12+
defer server.Close()
13+
14+
if !client.Caps().Has(imap.CapESearch) {
15+
t.Skip("server doesn't support ESEARCH")
16+
}
17+
18+
criteria := imap.SearchCriteria{
19+
Header: []imap.SearchCriteriaHeaderField{{
20+
Key: "Message-Id",
21+
Value: "<[email protected]>",
22+
}},
23+
}
24+
options := imap.SearchOptions{
25+
ReturnCount: true,
26+
}
27+
data, err := client.Search(&criteria, &options).Wait()
28+
if err != nil {
29+
t.Fatalf("Search().Wait() = %v", err)
30+
}
31+
if want := uint32(1); data.Count != want {
32+
t.Errorf("Count = %v, want %v", data.Count, want)
33+
}
34+
}

0 commit comments

Comments
 (0)