diff options
author | tastytea | 2020-01-10 19:04:18 +0100 |
---|---|---|
committer | tastytea | 2020-01-10 19:09:22 +0100 |
commit | 67bded42feb2518eb0f40a1b29893e46fafe76d7 (patch) | |
tree | 16a22b440f9a98f6b8fe365cc9e163fd300393d4 | |
parent | fbcded6e1ebb5f2ffffa012588fe31c4368f9e91 (diff) | |
download | mastodonpp-67bded42feb2518eb0f40a1b29893e46fafe76d7.tar mastodonpp-67bded42feb2518eb0f40a1b29893e46fafe76d7.tar.gz mastodonpp-67bded42feb2518eb0f40a1b29893e46fafe76d7.zip |
Add tests for Instance.
-rw-r--r-- | tests/test_instance.cpp (renamed from tests/test_instanciation.cpp) | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/test_instanciation.cpp b/tests/test_instance.cpp index bde806a..8e38275 100644 --- a/tests/test_instanciation.cpp +++ b/tests/test_instance.cpp @@ -15,7 +15,6 @@ */ #include "instance.hpp" -#include "connection.hpp" #include <catch.hpp> @@ -27,7 +26,7 @@ namespace mastodonpp using std::string; -SCENARIO ("Instantiations.") +SCENARIO ("mastopp::Instance") { bool exception = false; @@ -35,7 +34,7 @@ SCENARIO ("Instantiations.") { try { - Instance instance{"example.com", ""}; + Instance instance{"example.com", {}}; } catch (const std::exception &e) { @@ -48,12 +47,17 @@ SCENARIO ("Instantiations.") } } - WHEN ("Connection is instantiated.") + WHEN ("Variables are set.") { + constexpr auto hostname{"likeable.space"}; + constexpr auto proxy{"socks4a://[::1]:9050"}; + constexpr auto access_token{"abc123"}; + Instance instance{hostname, {}}; + try { - Instance instance{"example.com", ""}; - Connection connection{instance}; + instance.set_proxy(proxy); + instance.set_access_token(access_token); } catch (const std::exception &e) { @@ -61,8 +65,16 @@ SCENARIO ("Instantiations.") } THEN ("No exception is thrown") + AND_THEN ("get_proxy() returns the set value.") + AND_THEN ("get_access_token() returns the set value.") + AND_THEN ("get_hostname() returns the set value.") + AND_THEN ("get_baseuri() returns the expected value.") { REQUIRE_FALSE(exception); + REQUIRE(instance.get_proxy() == proxy); + REQUIRE(instance.get_access_token() == access_token); + REQUIRE(instance.get_hostname() == hostname); + REQUIRE(instance.get_baseuri() == (string("https://") += hostname)); } } } |