From 35778de6e00cb648dc7fcc0084c50f6c3ff2f0ca Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 20 Apr 2019 00:17:27 +0200 Subject: [PATCH] Added tests for API::v1::follow_requests_id_authorize. --- .../test_api_v1_follow_requests_authorize.cpp | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/test_api_v1_follow_requests_authorize.cpp diff --git a/tests/test_api_v1_follow_requests_authorize.cpp b/tests/test_api_v1_follow_requests_authorize.cpp new file mode 100644 index 0000000..a91e02f --- /dev/null +++ b/tests/test_api_v1_follow_requests_authorize.cpp @@ -0,0 +1,64 @@ +/* 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 "environment_variables.hpp" + +using namespace Mastodon; + +SCENARIO ("/api/v1/follow_requests/:id/authorize can be called successfully", + "[api][mastodon][pleroma][glitch-soc]") +{ + REQUIRE (access_token != nullptr); + + GIVEN ("instance = " + instance) + { + Mastodon::Easy::API masto(instance, access_token); + return_call ret; + bool exception = false; + + WHEN ("POST /api/v1/follow_requests/abc123/authorize is called") + { + try + { + ret = masto.post(API::v1::follow_requests_id_authorize, + {{ "id", { "abc123" }}}); + } + 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 == 111); + REQUIRE(ret.http_error_code == 404); + + REQUIRE(ret.answer.substr(0, 5) == "{\"err"); + } + } + } +} +