Deleting the Shopping List

Testing the delete endpoint is similar to testing the creation endpoint. We will first need to create a Shopping List and then extract the id from the response and make a DELETE request to the Shopping List endpoint. We can then verify that it deleted the Shopping List by checking the /shopping_lists endpoint and confirming that there are no Shopping Lists saved in the database:

  func testShoppingListDelete() throws {    let shoppingListName = "Shopping List Test Name"    var reqBody = JSON()    try reqBody.set("name", shoppingListName)        let list = try drop      .testResponse(to: .post,                    at: "/shopping_lists",                    headers: ["content-type": "application/json"],                    body: reqBody)    try list      .assertStatus(is: .ok) .assertJSON("name", equals: ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.