1 defmodule Mix.Tasks.Pleroma.RobotsTxtTest do
2 use ExUnit.Case, async: true
3 alias Mix.Tasks.Pleroma.RobotsTxt
5 test "creates new dir" do
6 path = "test/fixtures/new_dir/"
7 file_path = path <> "robots.txt"
9 static_dir = Pleroma.Config.get([:instance, :static_dir])
10 Pleroma.Config.put([:instance, :static_dir], path)
13 Pleroma.Config.put([:instance, :static_dir], static_dir)
14 {:ok, ["test/fixtures/new_dir/", "test/fixtures/new_dir/robots.txt"]} = File.rm_rf(path)
17 RobotsTxt.run(["disallow_all"])
19 assert File.exists?(file_path)
20 {:ok, file} = File.read(file_path)
22 assert file == "User-Agent: *\nDisallow: /\n"
25 test "to existance folder" do
26 path = "test/fixtures/"
27 file_path = path <> "robots.txt"
28 static_dir = Pleroma.Config.get([:instance, :static_dir])
29 Pleroma.Config.put([:instance, :static_dir], path)
32 Pleroma.Config.put([:instance, :static_dir], static_dir)
33 :ok = File.rm(file_path)
36 RobotsTxt.run(["disallow_all"])
38 assert File.exists?(file_path)
39 {:ok, file} = File.read(file_path)
41 assert file == "User-Agent: *\nDisallow: /\n"