diff options
author | lain <lain@soykaf.club> | 2023-02-09 19:50:59 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2023-02-09 19:50:59 +0000 |
commit | 755279e25370a2363ce767c5df16eedee4e9526f (patch) | |
tree | 30772f8fdf282e463b38159281417d48b4690e56 /test | |
parent | a7079057a9bf98612cc83255370107ace9af2efc (diff) | |
parent | 97f947deaf0afd908d9bd2cfa868a1e0e3e291d0 (diff) | |
download | pleroma-755279e25370a2363ce767c5df16eedee4e9526f.tar.gz pleroma-755279e25370a2363ce767c5df16eedee4e9526f.zip |
Merge branch 'tusooa/api-spec-property-map' into 'develop'
OpenApiSpex: overhaul
See merge request pleroma/pleroma!3832
Diffstat (limited to 'test')
-rw-r--r-- | test/mix/tasks/pleroma/openapi_spec_test.exs | 62 |
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 |