summaryrefslogtreecommitdiffstats
path: root/test/test_app.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_app.py')
-rw-r--r--test/test_app.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test_app.py b/test/test_app.py
new file mode 100644
index 0000000..cbbc6d5
--- /dev/null
+++ b/test/test_app.py
@@ -0,0 +1,21 @@
+"""Test for app module."""
+from pathlib import Path
+
+from ansiblelint.file_utils import Lintable
+from ansiblelint.testing import run_ansible_lint
+
+
+def test_generate_ignore(tmp_path: Path) -> None:
+ """Validate that --generate-ignore dumps expected ignore to the file."""
+ lintable = Lintable(tmp_path / "vars.yaml")
+ lintable.content = "foo: bar\nfoo: baz\n"
+ lintable.write(force=True)
+ assert not (tmp_path / ".ansible-lint-ignore").exists()
+ result = run_ansible_lint(lintable.filename, "--generate-ignore", cwd=str(tmp_path))
+ assert result.returncode == 2
+ assert (tmp_path / ".ansible-lint-ignore").exists()
+ with open(tmp_path / ".ansible-lint-ignore", encoding="utf-8") as f:
+ assert "vars.yaml yaml[key-duplicates]\n" in f.readlines()
+ # Run again and now we expect to succeed as we have an ignore file.
+ result = run_ansible_lint(lintable.filename, cwd=str(tmp_path))
+ assert result.returncode == 0