]> gitweb.factorcode.org Git - factor.git/blob - extra/pop3/pop3-tests.factor
Reformat
[factor.git] / extra / pop3 / pop3-tests.factor
1 ! Copyright (C) 2009 Elie Chaftari.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: concurrency.promises namespaces kernel pop3 pop3.server
4 sequences tools.test accessors calendar ;
5
6 FROM: pop3 => count delete ;
7
8 <promise> "p1" set
9
10 { } [ "p1" get mock-pop3-server ] unit-test
11 { } [
12         <pop3-account>
13             "127.0.0.1" >>host
14             "p1" get 5 seconds ?promise-timeout >>port
15         connect
16 ] unit-test
17 { } [ "username@host.com" >user ] unit-test
18 { } [ "password" >pwd ] unit-test
19 { { "CAPA" "TOP" "UIDL" } } [ capa ] unit-test
20 { 2 } [ count ] unit-test
21 { H{ { 1 "1006" } { 2 "747" } } } [ list ] unit-test
22 {
23     H{
24         { "From:" "from.first@mail.com" }
25         { "Subject:" "First test with mock POP3 server" }
26         { "To:" "username@host.com" }
27     }
28 } [ 1 0 top drop headers ] unit-test
29 {
30     {
31         T{ message
32             { # 1 }
33             { uidl "000000d547ac2fc2" }
34             { from "from.first@mail.com" }
35             { to "username@host.com" }
36             { subject "First test with mock POP3 server" }
37             { size "1006" }
38         }
39         T{ message
40             { # 2 }
41             { uidl "000000d647ac2fc2" }
42             { from "from.second@mail.com" }
43             { to "username@host.com" }
44             { subject "Second test with mock POP3 server" }
45             { size "747" }
46         }
47     }
48 } [ consolidate ] unit-test
49 { "000000d547ac2fc2" } [ 1 uidl ] unit-test
50 { } [ 1 delete ] unit-test
51 { } [ reset ] unit-test
52 { } [ close ] unit-test
53
54
55 <promise> "p2" set
56
57 { } [ "p2" get mock-pop3-server ] unit-test
58 { } [
59         <pop3-account>
60             "127.0.0.1" >>host
61             "p2" get 5 seconds ?promise-timeout >>port
62             "username@host.com" >>user
63             "password" >>pwd
64         connect
65 ] unit-test
66 { f } [ 1 retrieve empty? ] unit-test
67 { } [ close ] unit-test