Simplyfied and reduced calls in tests greatly.
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
2c6997827f
commit
5875adf5db
|
@ -26,57 +26,17 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, user id and return_call")
|
|
||||||
{
|
|
||||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
const string user_id =
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
return_call ret;
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
bool exception = false;
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, "");
|
|
||||||
bool username_found = false;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + " is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.get(API::v1::accounts_id,
|
|
||||||
{{ "id", { user_id }}});
|
|
||||||
username_found =
|
|
||||||
ret.answer.find("\"username\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(username_found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, "");
|
Mastodon::Easy::API masto(instance, "");
|
||||||
|
return_call ret;
|
||||||
Easy::Account account;
|
Easy::Account account;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + " is called")
|
WHEN ("/api/v1/accounts/" + user_id + " is called")
|
||||||
{
|
{
|
||||||
|
@ -91,23 +51,20 @@ SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
||||||
exception = true;
|
exception = true;
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("No exception is thrown")
|
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_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE(ret.http_error_code == 200);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
REQUIRE(account.valid());
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
REQUIRE(account.id() == user_id);
|
||||||
{
|
|
||||||
REQUIRE(account.username() != "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,71 +27,21 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/follow can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/follow can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
|
||||||
{
|
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance =
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
const string user_id =
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
return_call ret;
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
bool exception = false;
|
|
||||||
bool following_found = false;
|
|
||||||
bool error_found = false;
|
|
||||||
|
|
||||||
// You can't follow yourself, so we look for errors too.
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, access_token);
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/follow is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.post(API::v1::accounts_id_follow,
|
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
});
|
|
||||||
following_found =
|
|
||||||
ret.answer.find("\"following\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
error_found = following_found =
|
|
||||||
ret.answer.find("\"error")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No unexpected errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE((ret.error_code == 0
|
|
||||||
|| ret.error_code == 111));
|
|
||||||
REQUIRE((ret.http_error_code == 200
|
|
||||||
|| ret.http_error_code == 500));
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE((following_found || error_found));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
|
return_call ret;
|
||||||
Easy::Relationship relationship;
|
Easy::Relationship relationship;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/follow is called")
|
WHEN ("/api/v1/accounts/" + user_id + "/follow is called")
|
||||||
{
|
{
|
||||||
|
@ -108,23 +58,22 @@ SCENARIO ("/api/v1/accounts/:id/follow can be called successfully",
|
||||||
exception = true;
|
exception = true;
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("No exception is thrown")
|
THEN("No exception is thrown")
|
||||||
|
AND_THEN ("No unexpected errors are returned")
|
||||||
|
AND_THEN ("The answer makes sense")
|
||||||
{
|
{
|
||||||
REQUIRE_FALSE(exception);
|
REQUIRE_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No unexpected errors are returned")
|
// You can't follow yourself, so we look for errors too.
|
||||||
{
|
|
||||||
REQUIRE((ret.error_code == 0
|
REQUIRE((ret.error_code == 0
|
||||||
|| ret.error_code == 111));
|
|| ret.error_code == 111));
|
||||||
REQUIRE((ret.http_error_code == 200
|
REQUIRE((ret.http_error_code == 200
|
||||||
|| ret.http_error_code == 500));
|
|| ret.http_error_code == 500));
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE((relationship.following()
|
REQUIRE((relationship.following()
|
||||||
|| relationship.error() != ""));
|
|| relationship.error() != ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,68 +27,20 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/followers can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/followers can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
|
||||||
{
|
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance =
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
const string user_id =
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
return_call ret;
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
bool exception = false;
|
|
||||||
bool username_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, access_token);
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/followers is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.get(API::v1::accounts_id_followers,
|
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
{ "limit", { "5" } }
|
|
||||||
});
|
|
||||||
if (ret.answer == "[]")
|
|
||||||
{
|
|
||||||
WARN("No followers found.");
|
|
||||||
}
|
|
||||||
username_found =
|
|
||||||
ret.answer.find("\"username\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(username_found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
|
return_call ret;
|
||||||
Easy::Account account;
|
Easy::Account account;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/followers is called")
|
WHEN ("/api/v1/accounts/" + user_id + "/followers is called")
|
||||||
{
|
{
|
||||||
|
@ -114,24 +66,21 @@ SCENARIO ("/api/v1/accounts/:id/followers can be called successfully",
|
||||||
exception = true;
|
exception = true;
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("No exception is thrown")
|
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_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE(ret.http_error_code == 200);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
REQUIRE(account.valid());
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(account.username() != "");
|
REQUIRE(account.username() != "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,68 +27,20 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/following can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/following can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
|
||||||
{
|
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance =
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
const string user_id =
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
return_call ret;
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
bool exception = false;
|
|
||||||
bool username_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, access_token);
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/following is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.get(API::v1::accounts_id_following,
|
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
{ "limit", { "5" } }
|
|
||||||
});
|
|
||||||
if (ret.answer == "[]")
|
|
||||||
{
|
|
||||||
WARN("No followed found.");
|
|
||||||
}
|
|
||||||
username_found =
|
|
||||||
ret.answer.find("\"username\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(username_found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
|
return_call ret;
|
||||||
Easy::Account account;
|
Easy::Account account;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/following is called")
|
WHEN ("/api/v1/accounts/" + user_id + "/following is called")
|
||||||
{
|
{
|
||||||
|
@ -114,24 +66,21 @@ SCENARIO ("/api/v1/accounts/:id/following can be called successfully",
|
||||||
exception = true;
|
exception = true;
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("No exception is thrown")
|
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_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE(ret.http_error_code == 200);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
REQUIRE(account.valid());
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(account.username() != "");
|
REQUIRE(account.username() != "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,68 +27,20 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/statuses can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/statuses can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
|
||||||
{
|
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance =
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
const string user_id =
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
return_call ret;
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
bool exception = false;
|
|
||||||
bool content_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, access_token);
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/statuses is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.get(API::v1::accounts_id_statuses,
|
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
{ "limit", { "5" } }
|
|
||||||
});
|
|
||||||
if (ret.answer == "[]")
|
|
||||||
{
|
|
||||||
WARN("No statuses found.");
|
|
||||||
}
|
|
||||||
content_found =
|
|
||||||
ret.answer.find("\"content\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(content_found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
|
return_call ret;
|
||||||
Easy::Status status;
|
Easy::Status status;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/statuses is called")
|
WHEN ("/api/v1/accounts/" + user_id + "/statuses is called")
|
||||||
{
|
{
|
||||||
|
@ -114,24 +66,22 @@ SCENARIO ("/api/v1/accounts/:id/statuses can be called successfully",
|
||||||
exception = true;
|
exception = true;
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("No exception is thrown")
|
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_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE(ret.http_error_code == 200);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(status.valid());
|
REQUIRE(status.valid());
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(status.content() != "");
|
REQUIRE(status.content() != "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,71 +27,20 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/unfollow can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/unfollow can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
|
||||||
{
|
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance =
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
const string user_id =
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
return_call ret;
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
bool exception = false;
|
|
||||||
bool following_found = true;
|
|
||||||
bool error_found = false;
|
|
||||||
|
|
||||||
// You can't unfollow yourself, so we look for errors too.
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, access_token);
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/unfollow is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.post(API::v1::accounts_id_unfollow,
|
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
});
|
|
||||||
following_found =
|
|
||||||
ret.answer.find("\"following\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
error_found = following_found =
|
|
||||||
ret.answer.find("\"error")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No unexpected errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE((ret.error_code == 0
|
|
||||||
|| ret.error_code == 111));
|
|
||||||
REQUIRE((ret.http_error_code == 200
|
|
||||||
|| ret.http_error_code == 500));
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE((!following_found || error_found));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
|
return_call ret;
|
||||||
Easy::Relationship relationship;
|
Easy::Relationship relationship;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/unfollow is called")
|
WHEN ("/api/v1/accounts/" + user_id + "/unfollow is called")
|
||||||
{
|
{
|
||||||
|
@ -109,22 +58,20 @@ SCENARIO ("/api/v1/accounts/:id/unfollow can be called successfully",
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
THEN("No exception is thrown")
|
THEN("No exception is thrown")
|
||||||
|
AND_THEN ("No unexpected errors are returned")
|
||||||
|
AND_THEN ("The answer makes sense")
|
||||||
{
|
{
|
||||||
REQUIRE_FALSE(exception);
|
REQUIRE_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No unexpected errors are returned")
|
// You can't unfollow yourself, so we look for errors too.
|
||||||
{
|
|
||||||
REQUIRE((ret.error_code == 0
|
REQUIRE((ret.error_code == 0
|
||||||
|| ret.error_code == 111));
|
|| ret.error_code == 111));
|
||||||
REQUIRE((ret.http_error_code == 200
|
REQUIRE((ret.http_error_code == 200
|
||||||
|| ret.http_error_code == 500));
|
|| ret.http_error_code == 500));
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE((!relationship.following()
|
REQUIRE((!relationship.following()
|
||||||
|| relationship.error() != ""));
|
|| relationship.error() != ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,67 +27,20 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/relationships can be called successfully",
|
SCENARIO ("/api/v1/accounts/relationships can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
|
||||||
{
|
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance =
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
const string user_id =
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
return_call ret;
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
bool exception = false;
|
|
||||||
bool id_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, access_token);
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/relationships is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.get(API::v1::accounts_relationships,
|
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
});
|
|
||||||
if (ret.answer == "[]")
|
|
||||||
{
|
|
||||||
WARN("No relationships found.");
|
|
||||||
}
|
|
||||||
id_found =
|
|
||||||
ret.answer.find("\"id\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(id_found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
|
return_call ret;
|
||||||
Easy::Relationship relationship;
|
Easy::Relationship relationship;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/relationships is called")
|
WHEN ("/api/v1/accounts/relationships is called")
|
||||||
{
|
{
|
||||||
|
@ -112,24 +65,21 @@ SCENARIO ("/api/v1/accounts/relationships can be called successfully",
|
||||||
exception = true;
|
exception = true;
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("No exception is thrown")
|
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_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE(ret.http_error_code == 200);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(relationship.valid());
|
REQUIRE(relationship.valid());
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(relationship.id() != "");
|
REQUIRE(relationship.id() != "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,56 +27,20 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/update_credentials can be called successfully",
|
SCENARIO ("/api/v1/accounts/update_credentials can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token and return_call")
|
|
||||||
{
|
|
||||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
return_call ret;
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
bool exception = false;
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
bool display_name_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, access_token);
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/update_credentials is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.patch(API::v1::accounts_update_credentials,
|
|
||||||
{{ "display_name", { "testaccount" } }});
|
|
||||||
display_name_found =
|
|
||||||
ret.answer.find("\"display_name\":\"testaccount\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(display_name_found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
|
return_call ret;
|
||||||
Easy::Account account;
|
Easy::Account account;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/update_credentials is called")
|
WHEN ("/api/v1/accounts/update_credentials is called")
|
||||||
{
|
{
|
||||||
|
@ -91,23 +55,20 @@ SCENARIO ("/api/v1/accounts/update_credentials can be called successfully",
|
||||||
exception = true;
|
exception = true;
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("No exception is thrown")
|
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_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE(ret.http_error_code == 200);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
REQUIRE(account.valid());
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
REQUIRE(account.id() == user_id);
|
||||||
{
|
|
||||||
REQUIRE(account.display_name() == "testaccount");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,54 +27,20 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/verify_credentials can be called successfully",
|
SCENARIO ("/api/v1/accounts/verify_credentials can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token and return_call")
|
|
||||||
{
|
|
||||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
return_call ret;
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
bool exception = false;
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
bool username_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, access_token);
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/verify_credentials is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.get(API::v1::accounts_verify_credentials);
|
|
||||||
username_found = ret.answer.find(
|
|
||||||
"\"username\":\"testaccount\"") != std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(username_found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
|
return_call ret;
|
||||||
Easy::Account account;
|
Easy::Account account;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/verify_credentials is called")
|
WHEN ("/api/v1/accounts/verify_credentials is called")
|
||||||
{
|
{
|
||||||
|
@ -88,24 +54,22 @@ SCENARIO ("/api/v1/accounts/verify_credentials can be called successfully",
|
||||||
exception = true;
|
exception = true;
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("No exception is thrown")
|
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_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE(ret.http_error_code == 200);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
REQUIRE(account.valid());
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
REQUIRE(account.id() == user_id);
|
||||||
{
|
|
||||||
REQUIRE(account.username() == "testaccount");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,52 +26,14 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/instance can be called successfully",
|
SCENARIO ("/api/v1/instance can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance and return_call")
|
|
||||||
{
|
|
||||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||||
return_call ret;
|
GIVEN ("instance = " + instance)
|
||||||
bool exception = false;
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
|
||||||
{
|
|
||||||
Mastodon::API masto(instance, "");
|
|
||||||
bool uri_found = false;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/instance is called")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret = masto.get(API::v1::instance);
|
|
||||||
uri_found =
|
|
||||||
ret.answer.find("\"uri\":\"https://likeable.space\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(uri_found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
{
|
||||||
Mastodon::Easy::API masto(instance, "");
|
Mastodon::Easy::API masto(instance, "");
|
||||||
|
return_call ret;
|
||||||
Easy::Instance instance_;
|
Easy::Instance instance_;
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
WHEN ("/api/v1/instance is called")
|
WHEN ("/api/v1/instance is called")
|
||||||
{
|
{
|
||||||
|
@ -85,24 +47,22 @@ SCENARIO ("/api/v1/instance can be called successfully",
|
||||||
exception = true;
|
exception = true;
|
||||||
WARN(e.what());
|
WARN(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("No exception is thrown")
|
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_FALSE(exception);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE(ret.http_error_code == 200);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(instance_.valid());
|
REQUIRE(instance_.valid());
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
REQUIRE(instance_.uri() == ("https://" + instance));
|
||||||
{
|
|
||||||
REQUIRE(instance_.uri() == "https://likeable.space");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
SCENARIO ("Instantiating API classes works")
|
SCENARIO ("Instantiating API classes works")
|
||||||
{
|
{
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
|
|
||||||
WHEN ("Mastodon::API")
|
WHEN ("Mastodon::API")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -32,6 +33,7 @@ SCENARIO ("Instantiating API classes works")
|
||||||
{
|
{
|
||||||
exception = true;
|
exception = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN ("No exception is thrown")
|
THEN ("No exception is thrown")
|
||||||
{
|
{
|
||||||
REQUIRE_FALSE(exception);
|
REQUIRE_FALSE(exception);
|
||||||
|
@ -48,6 +50,7 @@ SCENARIO ("Instantiating API classes works")
|
||||||
{
|
{
|
||||||
exception = true;
|
exception = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN ("No exception is thrown")
|
THEN ("No exception is thrown")
|
||||||
{
|
{
|
||||||
REQUIRE_FALSE(exception);
|
REQUIRE_FALSE(exception);
|
||||||
|
|
Reference in New Issue