aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-13 17:26:25 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-13 17:26:25 +0100
commitefbbd480ddc62e695123d31c31d233b0df5155bd (patch)
treebc2fb465edd5050d83c97f280b1aac8e023fe3e5 /tests
After first pre-commit processing
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/test_merge_production_dotenvs_in_dotenv.py34
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/__init__.py
diff --git a/tests/test_merge_production_dotenvs_in_dotenv.py b/tests/test_merge_production_dotenvs_in_dotenv.py
new file mode 100644
index 0000000..c0e68f6
--- /dev/null
+++ b/tests/test_merge_production_dotenvs_in_dotenv.py
@@ -0,0 +1,34 @@
+from pathlib import Path
+
+import pytest
+
+from merge_production_dotenvs_in_dotenv import merge
+
+
+@pytest.mark.parametrize(
+ ("input_contents", "expected_output"),
+ [
+ ([], ""),
+ ([""], "\n"),
+ (["JANE=doe"], "JANE=doe\n"),
+ (["SEP=true", "AR=ator"], "SEP=true\nAR=ator\n"),
+ (["A=0", "B=1", "C=2"], "A=0\nB=1\nC=2\n"),
+ (["X=x\n", "Y=y", "Z=z\n"], "X=x\n\nY=y\nZ=z\n\n"),
+ ],
+)
+def test_merge(
+ tmp_path: Path,
+ input_contents: list[str],
+ expected_output: str,
+):
+ output_file = tmp_path / ".env"
+
+ files_to_merge = []
+ for num, input_content in enumerate(input_contents, start=1):
+ merge_file = tmp_path / f".service{num}"
+ merge_file.write_text(input_content)
+ files_to_merge.append(merge_file)
+
+ merge(output_file, files_to_merge)
+
+ assert output_file.read_text() == expected_output