1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

smtp_test: use assert false return, remove for loop

This commit is contained in:
Delyan Angelov 2020-07-13 18:52:46 +03:00
parent 97d01a5487
commit e3f7681e89

View File

@ -29,23 +29,20 @@ fn test_smtp() {
body: 'Plain text'
}
// This loop avoids `or { assert false return }` after each call; instead, it's replaced with
// `break`. There's an `assert false` after the loop, which will only be called if this loop
// is broken from.
for {
mut client := smtp.new_client(client_cfg) or { assert false break }
client.send(send_cfg) or { assert false break }
// client.send({ send_cfg | body_type: .html, body: '<html><h1>HTML V email!</h1></html>' }) or { break }
client.send({ send_cfg | from: 'alexander@vlang.io' }) or { assert false break }
client.send({ send_cfg | cc: 'alexander@vlang.io,joe@vlang.io', bcc: 'spytheman@vlang.io' }) or { assert false break }
client.send({ send_cfg | date: time.now().add_days(1000) }) or { assert false break }
client.quit() or { assert false break }
// This call should return an error, since the connection is closed
if !fn_errors(client, send_cfg) { assert false break }
client.reconnect() or { assert false break }
client.send(send_cfg) or { assert false break }
mut client := smtp.new_client(client_cfg) or { assert false return }
assert true
client.send(send_cfg) or { assert false return }
assert true
// client.send({ send_cfg | body_type: .html, body: '<html><h1>HTML V email!</h1></html>' }) or { assert false return }
client.send({ send_cfg | from: 'alexander@vlang.io' }) or { assert false return }
client.send({ send_cfg | cc: 'alexander@vlang.io,joe@vlang.io', bcc: 'spytheman@vlang.io' }) or { assert false return }
client.send({ send_cfg | date: time.now().add_days(1000) }) or { assert false return }
assert true
client.quit() or { assert false return }
assert true
// This call should return an error, since the connection is closed
if !fn_errors(client, send_cfg) { assert false return }
client.reconnect() or { assert false return }
client.send(send_cfg) or { assert false return }
assert true
return
}
assert false
}