MCPcopy Index your code
hub / github.com/foxcpp/maddy / TestImapStorageSwitch

Function TestImapStorageSwitch

tests/reload_test.go:98–255  ·  view source on GitHub ↗
(tt *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestImapStorageSwitch(tt *testing.T) {
99 if !sqliteprovider.IsTranspiled {
100 tt.Skip("Test is unstable with original SQLite")
101 }
102
103 tt.Parallel()
104 t := tests.NewT(tt)
105
106 t.DNS(nil)
107 t.Port("smtp")
108 t.Port("imap")
109 t.Config(`
110 storage.imapsql test_store {
111 driver sqlite3
112 dsn imapsql.db
113 }
114
115 imap tcp://127.0.0.1:{env:TEST_PORT_imap} {
116 tls off
117
118 auth dummy
119 storage &test_store
120 }
121
122 smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} {
123 hostname maddy.test
124 tls off
125
126 deliver_to &test_store
127 }
128 `)
129 t.Run(1)
130 defer t.Close()
131
132 imapConn := t.Conn("imap")
133 defer imapConn.Close()
134 imapConn.ExpectPattern(`\* OK *`)
135 imapConn.Writeln(". LOGIN testusr@maddy.test 1234")
136 imapConn.ExpectPattern(". OK *")
137 imapConn.Writeln(". SELECT INBOX")
138 imapConn.ExpectPattern(`\* *`)
139 imapConn.ExpectPattern(`\* *`)
140 imapConn.ExpectPattern(`\* *`)
141 imapConn.ExpectPattern(`\* *`)
142 imapConn.ExpectPattern(`\* *`)
143 imapConn.ExpectPattern(`\* *`)
144 imapConn.ExpectPattern(`. OK *`)
145
146 conn1 := t.Conn("smtp")
147 defer conn1.Close()
148 conn1.SMTPNegotation("localhost", nil, nil)
149 conn1.Writeln("MAIL FROM:<sender@maddy.test>")
150 conn1.ExpectPattern("2*")
151 conn1.Writeln("RCPT TO:<testusr@maddy.test>")
152 conn1.ExpectPattern("2*")
153 conn1.Writeln("DATA")
154 conn1.ExpectPattern("354 *")
155 conn1.Writeln("From: <sender@maddy.test>")

Callers

nothing calls this directly

Calls 13

DNSMethod · 0.95
PortMethod · 0.95
ConfigMethod · 0.95
RunMethod · 0.95
CloseMethod · 0.95
ConnMethod · 0.95
NewTFunction · 0.92
ExpectPatternMethod · 0.80
WritelnMethod · 0.80
SMTPNegotationMethod · 0.80
ExpectMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected