diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2019-07-11 13:26:59 +0700 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2019-07-11 13:26:59 +0700 |
commit | 182f7bbb1170c44eac4ab4a9efa4ff0bff991c98 (patch) | |
tree | f4c6fe46e82f667be49c8e6aad0ed3b418e4332f /test/tasks/robots_txt_test.exs | |
parent | ddd4a09b72ede65345ddf45a68eb239b54eda86c (diff) | |
parent | 4016341a77337e3b71295d27808eebc05152b086 (diff) | |
download | pleroma-182f7bbb1170c44eac4ab4a9efa4ff0bff991c98.tar.gz pleroma-182f7bbb1170c44eac4ab4a9efa4ff0bff991c98.zip |
Merge branch 'develop' into feature/addressable-lists
Diffstat (limited to 'test/tasks/robots_txt_test.exs')
-rw-r--r-- | test/tasks/robots_txt_test.exs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/tasks/robots_txt_test.exs b/test/tasks/robots_txt_test.exs new file mode 100644 index 000000000..97147a919 --- /dev/null +++ b/test/tasks/robots_txt_test.exs @@ -0,0 +1,47 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Mix.Tasks.Pleroma.RobotsTxtTest do + use ExUnit.Case, async: true + alias Mix.Tasks.Pleroma.RobotsTxt + + test "creates new dir" do + path = "test/fixtures/new_dir/" + file_path = path <> "robots.txt" + + static_dir = Pleroma.Config.get([:instance, :static_dir]) + Pleroma.Config.put([:instance, :static_dir], path) + + on_exit(fn -> + Pleroma.Config.put([:instance, :static_dir], static_dir) + {:ok, ["test/fixtures/new_dir/", "test/fixtures/new_dir/robots.txt"]} = File.rm_rf(path) + end) + + RobotsTxt.run(["disallow_all"]) + + assert File.exists?(file_path) + {:ok, file} = File.read(file_path) + + assert file == "User-Agent: *\nDisallow: /\n" + end + + test "to existance folder" do + path = "test/fixtures/" + file_path = path <> "robots.txt" + static_dir = Pleroma.Config.get([:instance, :static_dir]) + Pleroma.Config.put([:instance, :static_dir], path) + + on_exit(fn -> + Pleroma.Config.put([:instance, :static_dir], static_dir) + :ok = File.rm(file_path) + end) + + RobotsTxt.run(["disallow_all"]) + + assert File.exists?(file_path) + {:ok, file} = File.read(file_path) + + assert file == "User-Agent: *\nDisallow: /\n" + end +end |