Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2019 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. alias Mix.Tasks.Pleroma.RobotsTxt
  7. test "creates new dir" do
  8. path = "test/fixtures/new_dir/"
  9. file_path = path <> "robots.txt"
  10. static_dir = Pleroma.Config.get([:instance, :static_dir])
  11. Pleroma.Config.put([:instance, :static_dir], path)
  12. on_exit(fn ->
  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)
  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. static_dir = Pleroma.Config.get([:instance, :static_dir])
  25. Pleroma.Config.put([:instance, :static_dir], path)
  26. on_exit(fn ->
  27. Pleroma.Config.put([:instance, :static_dir], static_dir)
  28. :ok = File.rm(file_path)
  29. end)
  30. RobotsTxt.run(["disallow_all"])
  31. assert File.exists?(file_path)
  32. {:ok, file} = File.read(file_path)
  33. assert file == "User-Agent: *\nDisallow: /\n"
  34. end
  35. end