Annotation For tests/mail.rs
Logged in as anonymous

Lines of tests/mail.rs from check-in b9af445709 that are changed by the sequence of edits moving toward check-in f748e99b70:

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