diff options
author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-12 14:31:04 +0300 |
---|---|---|
committer | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-12 14:31:04 +0300 |
commit | 19ad94405695af366fc08bafc14ce306a44806d4 (patch) | |
tree | 42d5f8f1cc4e0331003b30a9ca0f5257c9e1a938 /test | |
parent | bf95bf34927f45b891c805797be454c06f34f8ff (diff) | |
download | pleroma-frontend-dl-task.tar.gz |
frontends dirfrontend-dl-task
Diffstat (limited to 'test')
-rw-r--r-- | test/instance_static/dist.zip | bin | 0 -> 790 bytes | |||
-rw-r--r-- | test/tasks/frontend_test.exs | 60 |
2 files changed, 60 insertions, 0 deletions
diff --git a/test/instance_static/dist.zip b/test/instance_static/dist.zip Binary files differnew file mode 100644 index 000000000..bec271c43 --- /dev/null +++ b/test/instance_static/dist.zip diff --git a/test/tasks/frontend_test.exs b/test/tasks/frontend_test.exs new file mode 100644 index 000000000..d72b03358 --- /dev/null +++ b/test/tasks/frontend_test.exs @@ -0,0 +1,60 @@ +defmodule Mix.Tasks.Pleroma.FrontendTest do + use ExUnit.Case + + import Tesla.Mock + + @path Pleroma.Config.get([:instance, :frontends_dir]) + + setup do + Mix.shell(Mix.Shell.Process) + + mock(fn + %{ + method: :get, + url: + "https://git.pleroma.social/pleroma/pleroma-fe/-/jobs/artifacts/master/download?job=build" + } -> + %Tesla.Env{status: 200, body: File.read!("test/instance_static/dist.zip")} + + %{ + method: :get, + url: + "https://git.pleroma.social/pleroma/pleroma-fe/-/jobs/artifacts/develop/download?job=build" + } -> + %Tesla.Env{status: 200, body: File.read!("test/instance_static/dist.zip")} + end) + + on_exit(fn -> + Mix.shell(Mix.Shell.IO) + {:ok, _} = File.rm_rf(@path) + end) + + :ok + end + + test "downloads pleroma-fe and master by default" do + Mix.Tasks.Pleroma.Frontend.run(["download"]) + + @path |> Path.expand() |> Path.join("pleroma-fe") |> check_assertions("master") + end + + test "download special fe with reference" do + ref = "develop" + Mix.Tasks.Pleroma.Frontend.run(["download", "-r", ref]) + + @path |> Path.expand() |> Path.join("pleroma-fe") |> check_assertions(ref) + end + + defp check_assertions(path, ref) do + assert_receive {:mix_shell, :info, [message]} + assert message == "Downloading reference #{ref}" + assert_receive {:mix_shell, :info, [message]} + assert message == "Cleaning #{path}" + assert_receive {:mix_shell, :info, [message]} + assert message == "Writing to #{path}" + assert_receive {:mix_shell, :info, ["Successfully downloaded and unpacked the frontend"]} + assert File.exists?(path <> "/1.png") + assert File.exists?(path <> "/2.css") + assert File.exists?(path <> "/3.js") + end +end |