Added tests for PUT and DELETE to API::v1::lists_id.
the build was successful Details

This commit is contained in:
tastytea 2019-04-25 17:25:39 +02:00
parent 9301586082
commit 8b3eaf1e73
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 58 additions and 2 deletions

View File

@ -246,7 +246,7 @@ You can select the instance to use with `MASTODON_CPP_INSTANCE`, the default is
default is *9hnrrVPriLiLVAhfVo*. You can select the status ID with
`MASTODON_CPP_STATUS_ID`, the default is *9hwnuJMq3eTdO4s1PU*. You can select
the filter ID with `MASTODON_CPP_FILTER_ID`. You can select the list ID with
`MASTODON_CPP_LIST_ID`, the default is *1*.
`MASTODON_CPP_LIST_ID`, the default is *2*.
Requirements for the test-user:

View File

@ -34,4 +34,4 @@ const string status_id = (env_status_id ? env_status_id : "9hwnuJMq3eTdO4s1PU");
const char *env_filter_id = getenv("MASTODON_CPP_FILTER_ID");
const string filter_id = (env_filter_id ? env_filter_id : "");
const char *env_list_id = getenv("MASTODON_CPP_LIST_ID");
const string list_id = (env_list_id ? env_list_id : "1");
const string list_id = (env_list_id ? env_list_id : "2");

View File

@ -65,6 +65,62 @@ SCENARIO ("/api/v1/lists/:id can be called successfully",
REQUIRE(list.id() == list_id);
}
}
WHEN ("PUT /api/v1/lists/" + list_id + " is called")
{
try
{
ret = masto.put(API::v1::lists_id,
{
{ "id", { list_id }},
{ "title", { "testlist" }}
});
list.from_string(ret.answer);
}
catch (const std::exception &e)
{
exception = true;
WARN(e.what());
}
THEN("No exception is thrown")
AND_THEN ("No errors are returned")
AND_THEN ("Answer is valid")
AND_THEN ("The answer makes sense")
{
REQUIRE_FALSE(exception);
REQUIRE(ret.error_code == 0);
REQUIRE(ret.http_error_code == 200);
REQUIRE(list.valid());
REQUIRE(list.title() == "testlist");
}
}
WHEN ("DELETE /api/v1/lists/donotdelete is called")
{
try
{
ret = masto.del(API::v1::lists_id,
{{ "id", { "donotdelete" }}});
}
catch (const std::exception &e)
{
exception = true;
WARN(e.what());
}
THEN("No exception is thrown")
AND_THEN ("No unexpected errors are returned")
{
REQUIRE_FALSE(exception);
REQUIRE(ret.error_code == 111);
REQUIRE(ret.http_error_code == 400);
}
}
}
}