Hi and welcome to this video on testing
DELETE calls. Now DELETE calls are pretty
self-explanatory,
they allow you to delete existing
resources from your service. As you can
imagine there's many things we want to
carefully test when it comes to deleting
things. You don't want to delete the
wrong things, we want to make sure that
we have all the right checks in place to
prevent things from being deleted that
should not be. This can take the form of
authentication and authorization, in
other words making sure you can't delete
other users content for example, or
making sure that only users with certain
permission levels can delete things. It
can also take the form of data types,
perhaps only certain things in your
service can be deleted, you might have
shared resources that you don't want to
allow people to delete, or you might not
allow deleting of objects until child
objects have been removed. Okay let's
take a look at an example. So here I have
a simple setup similar to the previous
videos, where we have a user so it's our
profile, and I've included the embed
parameter to embed the blog posts. So
we're doing a GET call here, so let's
just send that and see what this gets
back. So we get our user John Smith and
we get the blog post that belonged to
his ID. Now we can modify this as well so
let's change this, and we can see
comments that he has also contributed
some comments as well. So this user has
both blog posts and comments that are
associated with his profile. Now let's go
ahead and delete this user, and see what
happens. So we'll get rid of the
parameters here, so profile slash one and
we're going to do a DELETE. So we'll
delete this profile and we'll see what
happens. So we'll send that and we get
back an empty response, this profile no
longer exists, that's what we expect. And
now let's get on the blog posts and see
what happens. So blog posts, and we'll do
a GET and we'll send that, we can see
there's no blog post here, so the blog
post that were there before the blog
posts that were
associated with that user profile have
been removed. Now this may or may not we
want our application do, maybe we have a
requirement that all associated data be
removed when a users removed, or maybe we
want to keep the data from deleted users
so that common threads make more sense.
Whatever the business use case here we
can see the importance of checking what
happens to objects that are linked
together when deleting stuff in the
system. You could imagine that this could
be a bad thing, we might have deleted a
whole bunch of data that we shouldn't
have deleted with this call. And so we
want to be careful and check associated
data when we delete it, do we delete only
what we expect? Do we delete everything
that we expect to be deleted? We need to
check these kinds of things when testing
delete on an API. So at this point we've
covered the major REST API actions, we've
looked at GET, we looked at POST, we've
looked at PUT, and we've looked at DELETE,
and we've looked at ways that we can
think about testing these, we've looked
at a few simple examples to help get us
on the right track towards testing these.
And there of course other options that
are available, you can see it in Postman
here itself, when we do this drop down
there's quite a large link of different
options that are available. However if
you know these four and you're able to
use them and put them into practice, if
you understand how to think about
testing the four that we've covered,
you're well on your way to be in an API
testing professional. So at this point
we're ready to put it all into practice,
we're ready to take all that we've
learned and kind of try it out on a real
life challenge. And so I hope to see you
in the next video, where we'll talk about
the find the 500 testing challenge.