Skip to content

Commit

Permalink
imapclient: add basic SEARCH test
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Nov 20, 2024
1 parent a08f1dc commit 5a974f9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions imapclient/search_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
package imapclient_test

import (
"reflect"
"testing"

"github.com/emersion/go-imap/v2"
)

func TestSearch(t *testing.T) {
client, server := newClientServerPair(t, imap.ConnStateSelected)
defer client.Close()
defer server.Close()

criteria := imap.SearchCriteria{
Header: []imap.SearchCriteriaHeaderField{{
Key: "Message-Id",
Value: "<[email protected]>",
}},
}
data, err := client.Search(&criteria, nil).Wait()
if err != nil {
t.Fatalf("Search().Wait() = %v", err)
}
seqSet, ok := data.All.(imap.SeqSet)
if !ok {
t.Fatalf("SearchData.All = %T, want SeqSet", data.All)
}
nums, _ := seqSet.Nums()
want := []uint32{1}
if !reflect.DeepEqual(nums, want) {
t.Errorf("SearchData.All.Nums() = %v, want %v", nums, want)
}
}

func TestESearch(t *testing.T) {
client, server := newClientServerPair(t, imap.ConnStateSelected)
defer client.Close()
Expand Down

0 comments on commit 5a974f9

Please sign in to comment.