diff options
Diffstat (limited to 'test/tasks')
-rw-r--r-- | test/tasks/frontend_test.exs | 67 | ||||
-rw-r--r-- | test/tasks/instance_test.exs | 22 |
2 files changed, 87 insertions, 2 deletions
diff --git a/test/tasks/frontend_test.exs b/test/tasks/frontend_test.exs new file mode 100644 index 000000000..2f9458f89 --- /dev/null +++ b/test/tasks/frontend_test.exs @@ -0,0 +1,67 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Mix.Tasks.Pleroma.FrontendTest do + use ExUnit.Case + use Pleroma.Tests.Helpers + + import Tesla.Mock, only: [mock_global: 1, json: 1] + + @bundle_zip_path Path.absname("test/fixtures/tesla_mock/fe-bundle.zip") + + @dir "test/tmp/instance_static" + + setup_all do + Mix.shell(Mix.Shell.Process) + + on_exit(fn -> + Mix.shell(Mix.Shell.IO) + end) + + :ok + end + + setup do + mock_global(fn + %{method: :get, url: "https://git.pleroma.social/api/v4/projects/" <> rest} -> + if String.ends_with?(rest, "repository/branches") do + "test/fixtures/tesla_mock/gitlab-api-pleroma-fe-branches.json" + else + "test/fixtures/tesla_mock/gitlab-api-pleroma-fe-releases.json" + end + |> Path.absname() + |> File.read!() + |> Jason.decode!() + |> json() + + %{method: :get, url: _download_url} -> + %Tesla.Env{status: 200, body: File.read!(@bundle_zip_path)} + end) + + File.mkdir_p!(@dir) + on_exit(fn -> File.rm_rf(@dir) end) + + clear_config([:instance, :static_dir], @dir) + + :ok + end + + test "installations" do + frontends = ~w(pleroma kenoma mastodon admin) + refs = ~w(develop stable 1.2.3) + + Enum.each(frontends, fn frontend -> + Enum.each(refs, fn ref -> + Mix.Tasks.Pleroma.Frontend.run([ + "install", + frontend, + "--ref", + ref + ]) + + assert File.exists?(Path.join([@dir, "frontends/#{frontend}/#{ref}/index.html"])) + end) + end) + end +end diff --git a/test/tasks/instance_test.exs b/test/tasks/instance_test.exs index f6a4ba508..e46992ac1 100644 --- a/test/tasks/instance_test.exs +++ b/test/tasks/instance_test.exs @@ -2,7 +2,7 @@ # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> # SPDX-License-Identifier: AGPL-3.0-only -defmodule Pleroma.InstanceTest do +defmodule Mix.Tasks.Pleroma.InstanceTest do use ExUnit.Case setup do @@ -63,7 +63,21 @@ defmodule Pleroma.InstanceTest do "--uploads-dir", "test/uploads", "--static-dir", - "instance/static/" + "instance/static/", + "--fe-primary", + "pleroma", + "--fe-primary-ref", + "develop", + "--fe-mastodon", + "y", + "--fe-mastodon-ref", + "develop", + "--fe-admin", + "y", + "--fe-admin-ref", + "develop", + "--fe-static", + "y" ]) end @@ -82,6 +96,10 @@ defmodule Pleroma.InstanceTest do assert generated_config =~ "password: \"dbpass\"" assert generated_config =~ "configurable_from_database: true" assert generated_config =~ "http: [ip: {127, 0, 0, 1}, port: 4000]" + assert generated_config =~ ~s(primary: %{"name" => "pleroma", "ref" => "develop"}) + assert generated_config =~ ~s(mastodon: %{"name" => "mastodon", "ref" => "develop"}) + assert generated_config =~ ~s(admin: %{"name" => "admin", "ref" => "develop"}) + assert generated_config =~ "static: true" assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql() end |