summaryrefslogtreecommitdiffstats
path: root/test/TestRoleRelativePath.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:04:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:04:50 +0000
commit782f8df6e41f29dce2db4970a3ad84aaeb7d8c5f (patch)
tree3a88a542cd8074743d251881131510157cfc510b /test/TestRoleRelativePath.py
parentInitial commit. (diff)
downloadansible-lint-upstream.tar.xz
ansible-lint-upstream.zip
Adding upstream version 4.3.7.upstream/4.3.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/TestRoleRelativePath.py')
-rw-r--r--test/TestRoleRelativePath.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/TestRoleRelativePath.py b/test/TestRoleRelativePath.py
new file mode 100644
index 0000000..6c3163b
--- /dev/null
+++ b/test/TestRoleRelativePath.py
@@ -0,0 +1,52 @@
+# pylint: disable=preferred-module # FIXME: remove once migrated per GH-725
+import unittest
+
+from ansiblelint.rules import RulesCollection
+from ansiblelint.rules.RoleRelativePath import RoleRelativePath
+from ansiblelint.testing import RunFromText
+
+FAIL_TASKS = '''
+- name: template example
+ template:
+ src: ../templates/foo.j2
+ dest: /etc/file.conf
+- name: copy example
+ copy:
+ src: ../files/foo.conf
+ dest: /etc/foo.conf
+- name: win_template example
+ win_template:
+ src: ../win_templates/file.conf.j2
+ dest: file.conf
+- name: win_copy example
+ win_copy:
+ src: ../files/foo.conf
+ dest: renamed-foo.conf
+'''
+
+SUCCESS_TASKS = '''
+- name: content example with no src
+ copy:
+ content: '# This file was moved to /etc/other.conf'
+ dest: /etc/mine.conf
+- name: content example with no src
+ win_copy:
+ content: '# This file was moved to /etc/other.conf'
+ dest: /etc/mine.conf
+'''
+
+
+class TestRoleRelativePath(unittest.TestCase):
+ collection = RulesCollection()
+ collection.register(RoleRelativePath())
+
+ def setUp(self):
+ self.runner = RunFromText(self.collection)
+
+ def test_fail(self):
+ results = self.runner.run_role_tasks_main(FAIL_TASKS)
+ self.assertEqual(4, len(results))
+
+ def test_success(self):
+ results = self.runner.run_role_tasks_main(SUCCESS_TASKS)
+ self.assertEqual(0, len(results))