January 2019
Intermediate to advanced
520 pages
14h 32m
English
Our application also has a mailer microservice that sends notifications to users. It needs the utils module for testing only:
mod utils;use self::utils::{Method, WebApi};
Put the preceding code into a new mailer.rs file and add a healthcheck to test that a microservice instance is alive:
#[test]fn mails_healthcheck() { let mut api = WebApi::mailer(); api.healthcheck("/", "Mailer Microservice");}
The Mailer microservice also doesn't need to know users to notify them. It only requires an email address and some content. This microservice will send confirmation codes to a user, so let's simulate this behavior in our send_mail test:
#[test]fn send_mail() { let mut api = WebApi::mailer(); let email = utils::rand_str() + "@example.com"; ...Read now
Unlock full access