logo

pleroma

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

instance.exs (1991B)


      1 defmodule Pleroma.InstanceTest do
      2   use ExUnit.Case, async: true
      3 
      4   setup do
      5     File.mkdir_p!(tmp_path())
      6     on_exit(fn -> File.rm_rf(tmp_path()) end)
      7     :ok
      8   end
      9 
     10   defp tmp_path do
     11     "/tmp/generated_files/"
     12   end
     13 
     14   test "running gen" do
     15     mix_task = fn ->
     16       Mix.Tasks.Pleroma.Instance.run([
     17         "gen",
     18         "--output",
     19         tmp_path() <> "generated_config.exs",
     20         "--output-psql",
     21         tmp_path() <> "setup.psql",
     22         "--domain",
     23         "test.pleroma.social",
     24         "--instance-name",
     25         "Pleroma",
     26         "--admin-email",
     27         "admin@example.com",
     28         "--notify-email",
     29         "notify@example.com",
     30         "--dbhost",
     31         "dbhost",
     32         "--dbname",
     33         "dbname",
     34         "--dbuser",
     35         "dbuser",
     36         "--dbpass",
     37         "dbpass",
     38         "--indexable",
     39         "y",
     40         "--db-configurable",
     41         "y"
     42       ])
     43     end
     44 
     45     ExUnit.CaptureIO.capture_io(fn ->
     46       mix_task.()
     47     end)
     48 
     49     generated_config = File.read!(tmp_path() <> "generated_config.exs")
     50     assert generated_config =~ "host: \"test.pleroma.social\""
     51     assert generated_config =~ "name: \"Pleroma\""
     52     assert generated_config =~ "email: \"admin@example.com\""
     53     assert generated_config =~ "notify_email: \"notify@example.com\""
     54     assert generated_config =~ "hostname: \"dbhost\""
     55     assert generated_config =~ "database: \"dbname\""
     56     assert generated_config =~ "username: \"dbuser\""
     57     assert generated_config =~ "password: \"dbpass\""
     58     assert generated_config =~ "dynamic_configuration: true"
     59     assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
     60   end
     61 
     62   defp generated_setup_psql do
     63     ~s(CREATE USER dbuser WITH ENCRYPTED PASSWORD 'dbpass';\nCREATE DATABASE dbname OWNER dbuser;\n\\c dbname;\n--Extensions made by ecto.migrate that need superuser access\nCREATE EXTENSION IF NOT EXISTS citext;\nCREATE EXTENSION IF NOT EXISTS pg_trgm;\nCREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";\n)
     64   end
     65 end