1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.RobotsTxtTest do
7 alias Mix.Tasks.Pleroma.RobotsTxt
9 test "creates new dir" do
10 path = "test/fixtures/new_dir/"
11 file_path = path <> "robots.txt"
13 static_dir = Pleroma.Config.get([:instance, :static_dir])
14 Pleroma.Config.put([:instance, :static_dir], path)
17 Pleroma.Config.put([:instance, :static_dir], static_dir)
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 existance folder" do
30 path = "test/fixtures/"
31 file_path = path <> "robots.txt"
32 static_dir = Pleroma.Config.get([:instance, :static_dir])
33 Pleroma.Config.put([:instance, :static_dir], path)
36 Pleroma.Config.put([:instance, :static_dir], static_dir)
37 :ok = File.rm(file_path)
40 RobotsTxt.run(["disallow_all"])
42 assert File.exists?(file_path)
43 {:ok, file} = File.read(file_path)
45 assert file == "User-Agent: *\nDisallow: /\n"