logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

robots_txt_test.exs (1172B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Mix.Tasks.Pleroma.RobotsTxtTest do
  5. use ExUnit.Case
  6. use Pleroma.Tests.Helpers
  7. alias Mix.Tasks.Pleroma.RobotsTxt
  8. setup do: clear_config([:instance, :static_dir])
  9. test "creates new dir" do
  10. path = "test/fixtures/new_dir/"
  11. file_path = path <> "robots.txt"
  12. Pleroma.Config.put([:instance, :static_dir], path)
  13. on_exit(fn ->
  14. {:ok, ["test/fixtures/new_dir/", "test/fixtures/new_dir/robots.txt"]} = File.rm_rf(path)
  15. end)
  16. RobotsTxt.run(["disallow_all"])
  17. assert File.exists?(file_path)
  18. {:ok, file} = File.read(file_path)
  19. assert file == "User-Agent: *\nDisallow: /\n"
  20. end
  21. test "to existance folder" do
  22. path = "test/fixtures/"
  23. file_path = path <> "robots.txt"
  24. Pleroma.Config.put([:instance, :static_dir], path)
  25. on_exit(fn ->
  26. :ok = File.rm(file_path)
  27. end)
  28. RobotsTxt.run(["disallow_all"])
  29. assert File.exists?(file_path)
  30. {:ok, file} = File.read(file_path)
  31. assert file == "User-Agent: *\nDisallow: /\n"
  32. end
  33. end