summaryrefslogtreecommitdiffstats
path: root/pigeonhole/tests/extensions/imap4flags/flagstore.svtest
blob: bf114024c225b571f565f6a4e21087caed1ab263 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
require "vnd.dovecot.testsuite";
require "fileinto";
require "imap4flags";
require "relational";
require "comparator-i;ascii-numeric";
require "mailbox";

test_set "message" text:
From: Henry von Flockenstoffen <henry@example.com>
To: Dieter von Ausburg <dieter@example.com>
Subject: Test message.

Test message.
.
;

test "Basic" {
	if hasflag :comparator "i;ascii-numeric" :count "ge" "1" {
		test_fail "some flags or keywords are already set";
	}

	setflag "$label1 \\answered";

	fileinto :create "Uninteresting";

	if not test_result_execute {
		test_fail "failed to execute first result";
	}

	test_result_reset;

	setflag "\\draft \\seen Junk";

	fileinto "Uninteresting";

	if not test_result_execute {
		test_fail "failed to execute second result";
	}

	test_result_reset;

	fileinto :flags "\\flagged" "Uninteresting";

	if not test_result_execute {
		test_fail "failed to execute third result";
	}

	test_result_reset;

	test_message :folder "Uninteresting" 0;

	if not hasflag "$label1 \\answered" {
		test_fail "flags not stored for first message";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
		test_fail "invalid number of flags set for first message";
	}

	test_result_reset;

	test_message :folder "Uninteresting" 1;

	if not hasflag "\\draft \\seen Junk" {
		test_fail "flags not stored for second message";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "3" {
		test_fail "invalid number of flags set for second message";
	}

	test_result_reset;

	test_message :folder "Uninteresting" 2;

	if not hasflag "\\flagged" {
		test_fail "flags not stored for third message";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
		test_fail "invalid number of flags set for third message";
	}
}

test_result_reset;
test_set "message" text:
From: Henry von Flockenstoffen <henry@example.com>
To: Dieter von Ausburg <dieter@example.com>
Subject: Test message.

Test message.
.
;

test "Flag changes between stores" {
	if hasflag :comparator "i;ascii-numeric" :count "ge" "1" {
		test_fail "some flags or keywords are already set";
	}

	setflag "$label1 \\answered";
	fileinto :create "FolderA";

	setflag "$label2";
	fileinto :create "FolderB";

	fileinto :create :flags "\\seen \\draft \\flagged" "FolderC";

	if not test_result_execute {
		test_fail "failed to execute first result";
	}

	test_result_reset;
	test_message :folder "FolderA" 0;

	if not hasflag "\\answered $label1" {
		test_fail "flags not stored for first message";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
		test_fail "invalid number of flags set for first message";
	}

	test_result_reset;
	test_message :folder "FolderB" 0;

	if not hasflag "$label2" {
		test_fail "flag not stored for second message";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
		test_fail "invalid number of flags set for second message";
	}

	test_result_reset;
	test_message :folder "FolderC" 0;

	if not hasflag "\\seen \\flagged \\draft" {
		test_fail "flags not stored for third message";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "3" {
		test_fail "invalid number of flags set for third message";
	}
}