Smoke test to ensure message delivery is handled correctly.
(tt *testing.T)
| 30 | // Smoke test to ensure message delivery is handled correctly. |
| 31 | |
| 32 | func TestImapsqlDelivery(tt *testing.T) { |
| 33 | tt.Parallel() |
| 34 | t := tests.NewT(tt) |
| 35 | |
| 36 | t.DNS(nil) |
| 37 | t.Port("imap") |
| 38 | t.Port("smtp") |
| 39 | t.Config(` |
| 40 | storage.imapsql test_store { |
| 41 | driver sqlite3 |
| 42 | dsn imapsql.db |
| 43 | } |
| 44 | |
| 45 | imap tcp://127.0.0.1:{env:TEST_PORT_imap} { |
| 46 | tls off |
| 47 | |
| 48 | auth dummy |
| 49 | storage &test_store |
| 50 | } |
| 51 | |
| 52 | smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} { |
| 53 | hostname maddy.test |
| 54 | tls off |
| 55 | |
| 56 | deliver_to &test_store |
| 57 | } |
| 58 | `) |
| 59 | t.Run(2) |
| 60 | defer t.Close() |
| 61 | |
| 62 | imapConn := t.Conn("imap") |
| 63 | defer imapConn.Close() |
| 64 | imapConn.ExpectPattern(`\* OK *`) |
| 65 | imapConn.Writeln(". LOGIN testusr@maddy.test 1234") |
| 66 | imapConn.ExpectPattern(". OK *") |
| 67 | imapConn.Writeln(". SELECT INBOX") |
| 68 | imapConn.ExpectPattern(`\* *`) |
| 69 | imapConn.ExpectPattern(`\* *`) |
| 70 | imapConn.ExpectPattern(`\* *`) |
| 71 | imapConn.ExpectPattern(`\* *`) |
| 72 | imapConn.ExpectPattern(`\* *`) |
| 73 | imapConn.ExpectPattern(`\* *`) |
| 74 | imapConn.ExpectPattern(`. OK *`) |
| 75 | |
| 76 | smtpConn := t.Conn("smtp") |
| 77 | defer smtpConn.Close() |
| 78 | smtpConn.SMTPNegotation("localhost", nil, nil) |
| 79 | smtpConn.Writeln("MAIL FROM:<sender@maddy.test>") |
| 80 | smtpConn.ExpectPattern("2*") |
| 81 | smtpConn.Writeln("RCPT TO:<testusr@maddy.test>") |
| 82 | smtpConn.ExpectPattern("2*") |
| 83 | smtpConn.Writeln("DATA") |
| 84 | smtpConn.ExpectPattern("354 *") |
| 85 | smtpConn.Writeln("From: <sender@maddy.test>") |
| 86 | smtpConn.Writeln("To: <testusr@maddy.test>") |
| 87 | smtpConn.Writeln("Subject: Hi!") |
| 88 | smtpConn.Writeln("") |
| 89 | smtpConn.Writeln("Hi!") |
nothing calls this directly
no test coverage detected