Annotation For tests/mail.rs
Logged in as anonymous

Origin for each line in tests/mail.rs from check-in f4660639ca:

f4660639ca 2026-07-31    1: use smtp2tg::mail::MailServer;
f4660639ca 2026-07-31    2: 
f4660639ca 2026-07-31    3: use stacked_errors::{
f4660639ca 2026-07-31    4: 	Result,
f4660639ca 2026-07-31    5: 	StackableErr,
f4660639ca 2026-07-31    6: };
f4660639ca 2026-07-31    7: 
f4660639ca 2026-07-31    8: use tgbot::types::ChatPeerId;
f4660639ca 2026-07-31    9: /// Builds a `MailServer` purely from an in-memory TOML source, no
f4660639ca 2026-07-31   10: /// network access is performed while constructing it.
f4660639ca 2026-07-31   11: fn build_server () -> Result<MailServer> {
f4660639ca 2026-07-31   12: 	let settings = config::Config::builder()
f4660639ca 2026-07-31   13: 		.add_source(config::File::from_str(r#"
f4660639ca 2026-07-31   14: 			api_key = "test-api-key"
f4660639ca 2026-07-31   15: 			api_gateway = "https://api.telegram.org"
f4660639ca 2026-07-31   16: 			default = 0
f4660639ca 2026-07-31   17: 			unknown = "relay"
f4660639ca 2026-07-31   18: 			fields = ["date", "from", "subject"]
f4660639ca 2026-07-31   19: 			domains = ["example.com"]
f4660639ca 2026-07-31   20: 
f4660639ca 2026-07-31   21: 			[recipients]
f4660639ca 2026-07-31   22: 			"someone@example.com" = 1
f4660639ca 2026-07-31   23: 			"root" = -1
f4660639ca 2026-07-31   24: 		"#, config::FileFormat::Toml))
f4660639ca 2026-07-31   25: 		.build()
f4660639ca 2026-07-31   26: 		.stack()?;
f4660639ca 2026-07-31   27: 	MailServer::new(settings)
f4660639ca 2026-07-31   28: }
f4660639ca 2026-07-31   29: 
f4660639ca 2026-07-31   30: #[test]
f4660639ca 2026-07-31   31: fn get_id_returns_configured_recipient () -> Result<()> {
f4660639ca 2026-07-31   32: 	let server = build_server()?;
f4660639ca 2026-07-31   33: 	let cases = [
f4660639ca 2026-07-31   34: 		("someone@example.com", 1),
f4660639ca 2026-07-31   35: 		("someone", 0),
f4660639ca 2026-07-31   36: 		("root", -1),
f4660639ca 2026-07-31   37: 		("unknown@example.com", 0),
f4660639ca 2026-07-31   38: 	];
f4660639ca 2026-07-31   39: 	for (email, id) in cases {
f4660639ca 2026-07-31   40: 		assert_eq!(*server.get_id(email)?, ChatPeerId::from(id), "email [{email}] expected to return id [{id}]");
f4660639ca 2026-07-31   41: 	}
f4660639ca 2026-07-31   42: 	Ok(())
f4660639ca 2026-07-31   43: }