1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.RobotsTxtTest do
7 use Pleroma.Tests.Helpers
8 alias Mix.Tasks.Pleroma.RobotsTxt
10 setup do: clear_config([:instance, :static_dir])
12 test "creates new dir" do
13 path = "test/fixtures/new_dir/"
14 file_path = path <> "robots.txt"
15 clear_config([:instance, :static_dir], path)
18 {:ok, ["test/fixtures/new_dir/", "test/fixtures/new_dir/robots.txt"]} = File.rm_rf(path)
21 RobotsTxt.run(["disallow_all"])
23 assert File.exists?(file_path)
24 {:ok, file} = File.read(file_path)
26 assert file == "User-Agent: *\nDisallow: /\n"
29 test "to existing folder" do
30 path = "test/fixtures/"
31 file_path = path <> "robots.txt"
32 clear_config([:instance, :static_dir], path)
35 :ok = File.rm(file_path)
38 RobotsTxt.run(["disallow_all"])
40 assert File.exists?(file_path)
41 {:ok, file} = File.read(file_path)
43 assert file == "User-Agent: *\nDisallow: /\n"