From 91ef34faa4daf8352729f20cd2465c60677abdf2 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 25 Apr 2019 15:27:54 +0200 Subject: [PATCH] Added tests for API::v1::accounts_id_lists. --- tests/test_api_v1_accounts_id_lists.cpp | 65 +++++++++++++++++++++++++ tests/test_api_v1_lists.cpp | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 tests/test_api_v1_accounts_id_lists.cpp diff --git a/tests/test_api_v1_accounts_id_lists.cpp b/tests/test_api_v1_accounts_id_lists.cpp new file mode 100644 index 0000000..e12166f --- /dev/null +++ b/tests/test_api_v1_accounts_id_lists.cpp @@ -0,0 +1,65 @@ +/* This file is part of mastodon-cpp. + * Copyright © 2019 tastytea + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include "mastodon-cpp.hpp" +#include "easy/easy.hpp" +#include "easy/entities/list.hpp" +#include "environment_variables.hpp" + +using namespace Mastodon; + +SCENARIO ("/api/v1/accounts/:id/lists can be called successfully", + "[api][mastodon][pleroma][glitch-soc]") +{ + REQUIRE (access_token != nullptr); + + GIVEN ("instance = " + instance + ", user ID = " + user_id) + { + Mastodon::Easy::API masto(instance, access_token); + return_call ret; + bool exception = false; + + WHEN ("GET /api/v1/accounts/" + user_id + "/lists is called") + { + try + { + ret = masto.get(API::v1::accounts_id_lists, + {{ "id", { user_id }}}); + } + catch (const std::exception &e) + { + exception = true; + WARN(e.what()); + } + + THEN("No exception is thrown") + AND_THEN ("No unexpected errors are returned") + AND_THEN ("The answer makes sense") + { + REQUIRE_FALSE(exception); + + REQUIRE(ret.error_code == 0); + REQUIRE(ret.http_error_code == 200); + + REQUIRE(ret.answer == "[]"); + } + } + } +} + diff --git a/tests/test_api_v1_lists.cpp b/tests/test_api_v1_lists.cpp index 22e31a3..f77acd0 100644 --- a/tests/test_api_v1_lists.cpp +++ b/tests/test_api_v1_lists.cpp @@ -43,7 +43,7 @@ SCENARIO ("/api/v1/lists can be called successfully", ret = masto.get(API::v1::lists); if (ret.answer == "[]") { - WARN("No favourites found."); + WARN("No lists found."); } else {