forked from mailhog/storage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaildir_test.go
More file actions
69 lines (52 loc) · 1.55 KB
/
maildir_test.go
File metadata and controls
69 lines (52 loc) · 1.55 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package storage
import (
"testing"
)
func TestMaildirStore(t *testing.T) {
storage := CreateMaildir("testdata")
if storage.Count() != 0 {
t.Errorf("storage.Count() expected: %d, got: %d", 0, storage.Count())
}
fillStorage(storage, 25)
if storage.Count() != 25 {
t.Errorf("storage.Count() expected: %d, got: %d", 25, storage.Count())
}
storage.DeleteAll()
if storage.Count() != 0 {
t.Errorf("storage.Count() expected: %d, got: %d", 0, storage.Count())
}
}
func TestMaildirLoad(t *testing.T) {
storage := CreateMaildir("testdata")
storage.Store(newMessage("123"))
item, err := storage.Load("123")
if item == nil || err != nil {
t.Errorf("storage.Load(\"123\") expected: not nil, got: nil")
}
unexisting, err := storage.Load("321")
if unexisting != nil || err == nil {
t.Errorf("storage.Load(\"321\") expected: nil, got: not nil")
}
storage.DeleteAll()
}
func TestMaildirList(t *testing.T) {
storage := CreateMaildir("testdata")
fillStorage(storage, 25)
result, err := storage.List(0, 10)
if len(*result) != 10 || err != nil {
t.Errorf("len(result) expected: %d, got: %d", 10, len(*result))
}
result, err = storage.List(20, 30)
if len(*result) != 5 || err != nil {
t.Errorf("len(result) expected: %d, got: %d", 5, len(*result))
}
result, err = storage.List(20, 24)
if len(*result) != 5 || err != nil {
t.Errorf("len(result) expected: %d, got: %d", 5, len(*result))
}
result, err = storage.List(30, 40)
if len(*result) != 0 || err != nil {
t.Errorf("len(result) expected: %d, got: %d", 0, len(*result))
}
storage.DeleteAll()
}