Allowed the setting of the instance for testing.
the build was successful
Details
the build was successful
Details
Via the environment variable MASTODON_CPP_INSTANCE.
This commit is contained in:
parent
e00b99fb17
commit
0ffd41c851
11
README.md
11
README.md
|
@ -204,8 +204,15 @@ cmake options:
|
|||
* `-DWITH_DEB=YES` if you want to be able to generate a deb-package
|
||||
* `-DWITH_RPM=YES` if you want to be able to generate an rpm-package
|
||||
|
||||
You can run the tests with `ctest` inside the build directory.
|
||||
To install, run `make install`.
|
||||
Install with `make install`.
|
||||
|
||||
### Tests
|
||||
|
||||
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.
|
||||
You can select the instance to use with `MASTODON_CPP_INSTANCE`, the default is
|
||||
*likeable.space*.
|
||||
|
||||
### Packages
|
||||
|
||||
|
|
|
@ -26,15 +26,17 @@ using namespace Mastodon;
|
|||
SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
||||
"[api][mastodon][pleroma][glitch-soc]")
|
||||
{
|
||||
GIVEN ("id and return_call")
|
||||
GIVEN ("instance, id and return_call")
|
||||
{
|
||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||
const string id = "9hnrrVPriLiLVAhfVo";
|
||||
return_call ret;
|
||||
bool exception = false;
|
||||
|
||||
GIVEN ("Mastodon::API")
|
||||
{
|
||||
Mastodon::API masto("likeable.space", "");
|
||||
Mastodon::API masto(instance, "");
|
||||
bool username_found = false;
|
||||
|
||||
WHEN ("/api/v1/accounts/" + id + " is called")
|
||||
|
@ -68,7 +70,7 @@ SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
|||
|
||||
GIVEN ("Mastodon::Easy::API")
|
||||
{
|
||||
Mastodon::Easy::API masto("likeable.space", "");
|
||||
Mastodon::Easy::API masto(instance, "");
|
||||
Easy::Account account;
|
||||
|
||||
WHEN ("/api/v1/accounts/" + id + " is called")
|
||||
|
|
|
@ -27,8 +27,10 @@ using namespace Mastodon;
|
|||
SCENARIO ("/api/v1/accounts/update_credentials can be called successfully",
|
||||
"[api][mastodon][pleroma][glitch-soc]")
|
||||
{
|
||||
GIVEN ("access token and return_call")
|
||||
GIVEN ("instance, access token and return_call")
|
||||
{
|
||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||
return_call ret;
|
||||
bool exception = false;
|
||||
|
@ -38,7 +40,7 @@ SCENARIO ("/api/v1/accounts/update_credentials can be called successfully",
|
|||
|
||||
GIVEN ("Mastodon::API")
|
||||
{
|
||||
Mastodon::API masto("likeable.space", access_token);
|
||||
Mastodon::API masto(instance, access_token);
|
||||
|
||||
WHEN ("/api/v1/accounts/update_credentials is called")
|
||||
{
|
||||
|
@ -71,7 +73,7 @@ SCENARIO ("/api/v1/accounts/update_credentials can be called successfully",
|
|||
|
||||
GIVEN ("Mastodon::Easy::API")
|
||||
{
|
||||
Mastodon::Easy::API masto("likeable.space", access_token);
|
||||
Mastodon::Easy::API masto(instance, access_token);
|
||||
Easy::Account account;
|
||||
|
||||
WHEN ("/api/v1/accounts/update_credentials is called")
|
||||
|
|
|
@ -27,8 +27,10 @@ using namespace Mastodon;
|
|||
SCENARIO ("/api/v1/accounts/verify_credentials can be called successfully",
|
||||
"[api][mastodon][pleroma][glitch-soc]")
|
||||
{
|
||||
GIVEN ("access token and return_call")
|
||||
GIVEN ("instance, access token and return_call")
|
||||
{
|
||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||
return_call ret;
|
||||
bool exception = false;
|
||||
|
@ -38,7 +40,7 @@ SCENARIO ("/api/v1/accounts/verify_credentials can be called successfully",
|
|||
|
||||
GIVEN ("Mastodon::API")
|
||||
{
|
||||
Mastodon::API masto("likeable.space", access_token);
|
||||
Mastodon::API masto(instance, access_token);
|
||||
|
||||
WHEN ("/api/v1/accounts/verify_credentials is called")
|
||||
{
|
||||
|
@ -70,7 +72,7 @@ SCENARIO ("/api/v1/accounts/verify_credentials can be called successfully",
|
|||
|
||||
GIVEN ("Mastodon::Easy::API")
|
||||
{
|
||||
Mastodon::Easy::API masto("likeable.space", access_token);
|
||||
Mastodon::Easy::API masto(instance, access_token);
|
||||
Easy::Account account;
|
||||
|
||||
WHEN ("/api/v1/accounts/verify_credentials is called")
|
||||
|
|
|
@ -26,14 +26,16 @@ using namespace Mastodon;
|
|||
SCENARIO ("/api/v1/instance can be called successfully",
|
||||
"[api][mastodon][pleroma][glitch-soc]")
|
||||
{
|
||||
GIVEN ("return_call")
|
||||
GIVEN ("instance and return_call")
|
||||
{
|
||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||
return_call ret;
|
||||
bool exception = false;
|
||||
|
||||
GIVEN ("Mastodon::API")
|
||||
{
|
||||
Mastodon::API masto("likeable.space", "");
|
||||
Mastodon::API masto(instance, "");
|
||||
bool uri_found = false;
|
||||
|
||||
WHEN ("/api/v1/instance is called")
|
||||
|
@ -41,8 +43,9 @@ SCENARIO ("/api/v1/instance can be called successfully",
|
|||
try
|
||||
{
|
||||
ret = masto.get(API::v1::instance);
|
||||
uri_found = ret.answer.find(
|
||||
"\"uri\":\"https://likeable.space\"") != std::string::npos;
|
||||
uri_found =
|
||||
ret.answer.find("\"uri\":\"https://likeable.space\"")
|
||||
!= std::string::npos;
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
@ -66,15 +69,15 @@ SCENARIO ("/api/v1/instance can be called successfully",
|
|||
|
||||
GIVEN ("Mastodon::Easy::API")
|
||||
{
|
||||
Mastodon::Easy::API masto("likeable.space", "");
|
||||
Easy::Instance instance;
|
||||
Mastodon::Easy::API masto(instance, "");
|
||||
Easy::Instance instance_;
|
||||
|
||||
WHEN ("/api/v1/instance is called")
|
||||
{
|
||||
try
|
||||
{
|
||||
ret = masto.get(API::v1::instance);
|
||||
instance = Easy::Instance(ret.answer);
|
||||
instance_ = Easy::Instance(ret.answer);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
@ -91,11 +94,11 @@ SCENARIO ("/api/v1/instance can be called successfully",
|
|||
}
|
||||
THEN ("Answer is valid")
|
||||
{
|
||||
REQUIRE(instance.valid());
|
||||
REQUIRE(instance_.valid());
|
||||
}
|
||||
THEN ("The answer makes sense")
|
||||
{
|
||||
REQUIRE(instance.uri() == "https://likeable.space");
|
||||
REQUIRE(instance_.uri() == "https://likeable.space");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue