fix test
authorMaksim Pechnikov <parallel588@gmail.com>
Sat, 8 Aug 2020 03:49:19 +0000 (06:49 +0300)
committerMaksim Pechnikov <parallel588@gmail.com>
Thu, 15 Oct 2020 19:31:52 +0000 (22:31 +0300)
docs/administration/CLI_tasks/instance.md
lib/mix/tasks/pleroma/instance.ex
test/mix/tasks/pleroma/instance_test.exs

index d922b44dfb36b7a35023dd47b6860acd7cc6d4fe..982b22bf3c9223aef29aec7109d78b8329105b95 100644 (file)
@@ -41,3 +41,4 @@ If any of the options are left unspecified, you will be prompted interactively.
 - `--anonymize-uploads <Y|N>` - randomize uploaded filenames
 - `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames
 - `--skip-release-env` - skip generation the release environment file
+- `--release-env-file` - release environment file path
index caa7dfbd39cfbddf97f251896bcbbdabc7b3bc06..1915aacd9b2973092eebadd8adb708bf3d432371 100644 (file)
@@ -37,7 +37,8 @@ defmodule Mix.Tasks.Pleroma.Instance do
           strip_uploads: :string,
           anonymize_uploads: :string,
           dedupe_uploads: :string,
-          skip_release_env: :boolean
+          skip_release_env: :boolean,
+          release_env_file: :string
         ],
         aliases: [
           o: :output,
@@ -249,7 +250,15 @@ defmodule Mix.Tasks.Pleroma.Instance do
         """)
       else
         shell_info("Generation the environment file:")
-        Mix.Tasks.Pleroma.ReleaseEnv.run(["gen"])
+
+        release_env_args =
+          with path when not is_nil(path) <- Keyword.get(options, :release_env_file) do
+            ["gen", "--path", path]
+          else
+            _ -> ["gen"]
+          end
+
+        Mix.Tasks.Pleroma.ReleaseEnv.run(release_env_args)
       end
 
       shell_info(
index 8a02710ee2b336e7aed49b167de6217c711c6500..fe69a2def027b752dd0f44c9394c647658fac8bf 100644 (file)
@@ -5,6 +5,8 @@
 defmodule Mix.Tasks.Pleroma.InstanceTest do
   use ExUnit.Case
 
+  @release_env_file "./test/pleroma.test.env"
+
   setup do
     File.mkdir_p!(tmp_path())
 
@@ -16,6 +18,8 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
         File.rm_rf(Path.join(static_dir, "robots.txt"))
       end
 
+      if File.exists?(@release_env_file), do: File.rm_rf(@release_env_file)
+
       Pleroma.Config.put([:instance, :static_dir], static_dir)
     end)
 
@@ -69,7 +73,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
         "--dedupe-uploads",
         "n",
         "--anonymize-uploads",
-        "n"
+        "n",
+        "--release-env-file",
+        @release_env_file
       ])
     end
 
@@ -91,6 +97,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
     assert generated_config =~ "filters: [Pleroma.Upload.Filter.ExifTool]"
     assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
     assert File.exists?(Path.expand("./test/instance/static/robots.txt"))
+    assert File.exists?(@release_env_file)
+
+    assert File.read!(@release_env_file) =~ ~r/^RELEASE_COOKIE=.*/
   end
 
   defp generated_setup_psql do