January 2019
Intermediate to advanced
520 pages
14h 32m
English
Let's create a mock server that emulates responses for requests to three paths to a routing microservice: /signin, /signup, and /comments. There is the mockito crate that provides a server for emulating HTTP responses. We will use the example from Chapter 11, Involving Concurrency with Actors and the Actix Crate. Copy it and add these extra dependencies:
mockito = "0.15"reqwest = "0.9"
We need the mockito crate to start a server with mocks, and the reqwest crate to make HTTP requests to our Actix server instance.
Create a tests module with the #[cfg(test)] attribute that will be compiled for testing only, and import the following types that we will use for testing:
use crate::{start, Comment, LinksMap, UserForm, UserId};use lazy_static::lazy_static; ...Read now
Unlock full access