summaryrefslogtreecommitdiff
path: root/test/mix/tasks
diff options
context:
space:
mode:
authortusooa <tusooa@kazv.moe>2023-11-01 00:43:35 +0000
committertusooa <tusooa@kazv.moe>2023-11-01 00:43:35 +0000
commit6f654d534a1a606185c4f3543e7b1552f0a20566 (patch)
treeec8b787417a236aca411f0697465caf51d2b61ed /test/mix/tasks
parentf966abe4fbacf8fa91cf2b533f8abfb57d62f8b7 (diff)
parentad45b06b3f1d7dd4157a3fbc44dc1d2f07c98f35 (diff)
downloadpleroma-6f654d534a1a606185c4f3543e7b1552f0a20566.tar.gz
pleroma-6f654d534a1a606185c4f3543e7b1552f0a20566.zip
Merge branch 'release/2.6.0' into 'stable'
Release/2.6.0 See merge request pleroma/pleroma!3924
Diffstat (limited to 'test/mix/tasks')
-rw-r--r--test/mix/tasks/pleroma/openapi_spec_test.exs62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/mix/tasks/pleroma/openapi_spec_test.exs b/test/mix/tasks/pleroma/openapi_spec_test.exs
new file mode 100644
index 000000000..01437187a
--- /dev/null
+++ b/test/mix/tasks/pleroma/openapi_spec_test.exs
@@ -0,0 +1,62 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Mix.Tasks.Pleroma.OpenapiSpecTest do
+ use Pleroma.DataCase, async: true
+
+ alias Mix.Tasks.Pleroma.OpenapiSpec
+
+ @spec_base %{
+ "paths" => %{
+ "/cofe" => %{
+ "get" => %{
+ "operationId" => "Some.operation",
+ "tags" => []
+ }
+ },
+ "/mew" => %{
+ "post" => %{
+ "operationId" => "Another.operation",
+ "tags" => ["mew mew"]
+ }
+ }
+ },
+ "x-tagGroups" => [
+ %{
+ "name" => "mew",
+ "tags" => ["mew mew", "abc"]
+ },
+ %{
+ "name" => "lol",
+ "tags" => ["lol lol", "xyz"]
+ }
+ ]
+ }
+
+ describe "check_specs/1" do
+ test "Every operation must have a tag" do
+ assert {:error, ["Some.operation (get /cofe): No tags specified"]} ==
+ OpenapiSpec.check_specs(@spec_base)
+ end
+
+ test "Every tag must be in tag groups" do
+ spec =
+ @spec_base
+ |> put_in(["paths", "/cofe", "get", "tags"], ["abc", "def", "not specified"])
+
+ assert {:error,
+ [
+ "Some.operation (get /cofe): Tags #{inspect(["def", "not specified"])} not available. Please add it in \"x-tagGroups\" in Pleroma.Web.ApiSpec"
+ ]} == OpenapiSpec.check_specs(spec)
+ end
+
+ test "No errors if ok" do
+ spec =
+ @spec_base
+ |> put_in(["paths", "/cofe", "get", "tags"], ["abc", "mew mew"])
+
+ assert :ok == OpenapiSpec.check_specs(spec)
+ end
+ end
+end