Allowed the user ID for tests to be changed.
With the environment variable MASTODON_CPP_USER_ID.
This commit is contained in:
parent
09a234e82f
commit
ae7ac65931
|
@ -210,9 +210,10 @@ Install with `make install`.
|
|||
|
||||
You can run the tests with `ctest` inside the build directory. You need to set
|
||||
the environment variable `MASTODON_CPP_ACCESS_TOKEN` to an access token with the
|
||||
scopes *read*, *write*, *follow* and *push* for some tests.
|
||||
scopes *read*, *write* and *follow* for some tests.
|
||||
You can select the instance to use with `MASTODON_CPP_INSTANCE`, the default is
|
||||
*likeable.space*.
|
||||
*likeable.space*. You can select the user ID with `MASTODON_CPP_USER_ID`, the
|
||||
default is *9hnrrVPriLiLVAhfVo*.
|
||||
|
||||
### Packages
|
||||
|
||||
|
|
|
@ -26,11 +26,14 @@ using namespace Mastodon;
|
|||
SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
||||
"[api][mastodon][pleroma][glitch-soc]")
|
||||
{
|
||||
GIVEN ("instance, id and return_call")
|
||||
GIVEN ("instance, user id and return_call")
|
||||
{
|
||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||
const string id = "9hnrrVPriLiLVAhfVo";
|
||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||
const string user_id =
|
||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||
|
||||
return_call ret;
|
||||
bool exception = false;
|
||||
|
||||
|
@ -39,14 +42,15 @@ SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
|||
Mastodon::API masto(instance, "");
|
||||
bool username_found = false;
|
||||
|
||||
WHEN ("/api/v1/accounts/" + id + " is called")
|
||||
WHEN ("/api/v1/accounts/" + user_id + " is called")
|
||||
{
|
||||
try
|
||||
{
|
||||
ret = masto.get(API::v1::accounts_id,
|
||||
{{ "id", { id }}});
|
||||
username_found = ret.answer.find(
|
||||
"\"username\":\"testaccount\"") != std::string::npos;
|
||||
{{ "id", { user_id }}});
|
||||
username_found =
|
||||
ret.answer.find("\"username\":\"")
|
||||
!= std::string::npos;
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
@ -73,12 +77,12 @@ SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
|||
Mastodon::Easy::API masto(instance, "");
|
||||
Easy::Account account;
|
||||
|
||||
WHEN ("/api/v1/accounts/" + id + " is called")
|
||||
WHEN ("/api/v1/accounts/" + user_id + " is called")
|
||||
{
|
||||
try
|
||||
{
|
||||
ret = masto.get(API::v1::accounts_id,
|
||||
{{ "id", { id }}});
|
||||
{{ "id", { user_id }}});
|
||||
account = Easy::Account(ret.answer);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -100,7 +104,7 @@ SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
|||
}
|
||||
THEN ("The answer makes sense")
|
||||
{
|
||||
REQUIRE(account.username() == "testaccount");
|
||||
REQUIRE(account.username() != "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,14 @@ SCENARIO ("/api/v1/accounts/:id/followers can be called successfully",
|
|||
{
|
||||
GIVEN ("instance, access token, user id and return_call")
|
||||
{
|
||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||
const string instance =
|
||||
(env_instance ? env_instance : "likeable.space");
|
||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||
const string user_id = "9hnrrVPriLiLVAhfVo";
|
||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||
const string user_id =
|
||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||
|
||||
return_call ret;
|
||||
bool exception = false;
|
||||
bool username_found = false;
|
||||
|
|
|
@ -48,8 +48,9 @@ SCENARIO ("/api/v1/accounts/update_credentials can be called successfully",
|
|||
{
|
||||
ret = masto.patch(API::v1::accounts_update_credentials,
|
||||
{{ "display_name", { "testaccount" } }});
|
||||
display_name_found = ret.answer.find(
|
||||
"\"display_name\":\"testaccount\"") != std::string::npos;
|
||||
display_name_found =
|
||||
ret.answer.find("\"display_name\":\"testaccount\"")
|
||||
!= std::string::npos;
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
|
Reference in New Issue