-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
message_properties_test.go
39 lines (32 loc) · 838 Bytes
/
message_properties_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package notmuch
import (
"testing"
)
func TestMessagesProperties(t *testing.T) {
db, err := Open(dbPath, DBReadWrite)
if err != nil {
t.Fatal(err)
}
defer db.Close()
qs := "subject:\"Introducing myself\""
messages, err := db.NewQuery(qs).Messages()
if err != nil {
t.Fatalf("error getting the messages: %s", err)
}
first := &Message{}
found := messages.Next(&first)
if !found {
t.Fatalf("couldn't get the first message: %s", err)
}
if err := first.AddProperty("go-notmuch-test", "success"); err != nil {
t.Fatalf("couldn't add property: %s", err)
}
properties := first.Properties("go-notmuch-test", true)
property := &MessageProperty{}
for properties.Next(&property) {
if property.Key == "go-notmuch-test" && property.Value == "success" {
return
}
}
t.Fatalf("couldn't find expected property")
}