Testing the Routes: Use Case - Saving
Learn how to test the endpoints for saving an invalid and valid product and overwriting a product.
We'll cover the following...
Garbage value
We’ll continue with the use case of saving (or creating) a product via the API. We are going to generate junk data to test our APIs.
Press + to interact
val expectedStatus = StatusCodes.BadRequests"return $expectedStatus" in {for {resp <- http.singleRequest(HttpRequest(method = HttpMethods.POST,uri = s"$baseUrl/products",headers = Seq(),entity = HttpEntity(contentType = ContentTypes.`application/json`,data = ByteString(scala.util.Random.alphanumeric.take(256).mkString))))} yield {resp.status must be(expectedStatus)}}
Here, we test posting ...