forked from zenhack/go.notmuch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thread_test.go
47 lines (41 loc) · 1.29 KB
/
thread_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
40
41
42
43
44
45
46
47
package notmuch
// Copyright © 2015 The go.bindings Authors. Authors can be found in the AUTHORS file.
// Licensed under the GPLv3 or later.
// See COPYING at the root of the repository for details.
import "testing"
func TestGetThreadID(t *testing.T) {
db, err := Open(dbPath, DBReadOnly)
if err != nil {
t.Fatal(err)
}
defer db.Close()
threads, err := db.NewQuery("Essai accentué").Threads()
if err != nil {
t.Fatalf("error getting the threads: %s", err)
}
thread := &Thread{}
if !threads.Next(thread) {
t.Fatalf("threads.Next(thread): unable to fetch the first and only thread")
}
if want, got := "0000000000000014", thread.GetID(); want != got {
t.Errorf("db.NewQuery(%q).Threads().Get().GetID(): want %s got %s", want, want, got)
}
}
func TestGetSubjectUTF8(t *testing.T) {
db, err := Open(dbPath, DBReadOnly)
if err != nil {
t.Fatal(err)
}
defer db.Close()
threads, err := db.NewQuery("Essai accentué").Threads()
if err != nil {
t.Fatalf("error getting the threads: %s", err)
}
thread := &Thread{}
if !threads.Next(thread) {
t.Fatalf("threads.Next(thread): unable to fetch the first and only thread")
}
if want, got := "Essai accentué", thread.GetSubject(); want != got {
t.Errorf("db.NewQuery(%q).Threads().Get().GetSubject(): want %s got %s", want, want, got)
}
}