Types

Before we start implementing tests, we need to add some types that we need to interact with microservices. Create a types.rs source file with types:

use serde_derive::Deserialize;
use uuid::Uuid;

Now, add a UserId struct that will be used to parse raw responses from the users microservices (yes, we will also test it directly):

#[derive(Deserialize)]
pub struct UserId {
id: Uuid,
}

Also, add a Comment struct that we will use to post new comments to our content microservice:

#[derive(Deserialize)]
pub struct Comment {
pub id: i32,
pub uid: String,
pub text: String,
}

Now, we can write tests for every microservice separately, and after that, create a test for complex interaction.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.186.79