Added tests for PUT and DELETE to API::v1::lists_id.
All checks were successful
the build was successful
All checks were successful
the build was successful
This commit is contained in:
parent
9301586082
commit
8b3eaf1e73
@ -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:
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user