summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorbengerman13 <bengerman@gmail.com>2017-05-23 12:02:56 -0700
committerJames Cammarata <jimi@sngx.net>2017-06-01 12:14:21 -0500
commit081e98739ea837e02ac14e8d236770d08b7343e1 (patch)
treeeccdf4d6f7a4f2289d8aba80117be23de09d6f24 /test/integration
parentdd20427db9c19d1ec9bb61a789f29db6e947f4ae (diff)
downloadansible-081e98739ea837e02ac14e8d236770d08b7343e1.tar.gz
add integration tests for xattr module (#24947)
* add integration tests for xattr module * fix whitespace (cherry picked from commit 25aac6151f8848b701c5b952c1749cbe20ad134b)
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/targets/xattr/aliases1
-rw-r--r--test/integration/targets/xattr/defaults/main.yml1
-rw-r--r--test/integration/targets/xattr/tasks/main.yml68
-rw-r--r--test/integration/targets/xattr/tasks/setup.yml10
4 files changed, 80 insertions, 0 deletions
diff --git a/test/integration/targets/xattr/aliases b/test/integration/targets/xattr/aliases
new file mode 100644
index 0000000000..0f3ba0b2f8
--- /dev/null
+++ b/test/integration/targets/xattr/aliases
@@ -0,0 +1 @@
+destructive \ No newline at end of file
diff --git a/test/integration/targets/xattr/defaults/main.yml b/test/integration/targets/xattr/defaults/main.yml
new file mode 100644
index 0000000000..2ea8acbb4d
--- /dev/null
+++ b/test/integration/targets/xattr/defaults/main.yml
@@ -0,0 +1 @@
+test_file: ~/foo.txt \ No newline at end of file
diff --git a/test/integration/targets/xattr/tasks/main.yml b/test/integration/targets/xattr/tasks/main.yml
new file mode 100644
index 0000000000..8514c444f7
--- /dev/null
+++ b/test/integration/targets/xattr/tasks/main.yml
@@ -0,0 +1,68 @@
+- name: Setup
+ include: setup.yml
+
+- name: Set attributes
+ xattr:
+ path: "{{ test_file }}"
+ key: user.foo
+ value: bar
+ register: xattr_set_result
+
+- name: Get attributes
+ xattr:
+ path: "{{ test_file }}"
+ register: xattr_get_all_result
+
+- name: Get specific attribute
+ xattr:
+ path: "{{ test_file }}"
+ key: user.foo
+ register: xattr_get_specific_result
+
+- assert:
+ that:
+ - "xattr_set_result.changed"
+ - "xattr_get_all_result['xattr']['user.foo'] == 'bar'"
+ - "not xattr_get_all_result.changed"
+ - "xattr_get_specific_result['xattr']['user.foo'] == 'bar'"
+ - "not xattr_get_specific_result.changed"
+
+- name: Set attribute again
+ xattr:
+ path: "{{ test_file }}"
+ key: user.foo
+ value: bar
+ register: xattr_set_again_result
+
+- assert:
+ that:
+ - "not xattr_set_again_result.changed"
+
+- name: Unset attribute
+ xattr:
+ path: "{{ test_file }}"
+ key: user.foo
+ state: absent
+ register: xattr_unset_result
+
+- name: get attributes
+ xattr:
+ path: "{{ test_file }}"
+ register: xattr_get_after_unset_result
+
+- assert:
+ that:
+ - "xattr_unset_result.changed"
+ - "xattr_get_after_unset_result['xattr'] == {}"
+ - "not xattr_get_after_unset_result.changed"
+
+- name: Unset attribute again
+ xattr:
+ path: "{{ test_file }}"
+ key: user.foo
+ state: absent
+ register: xattr_unset_result
+
+- assert:
+ that:
+ - "not xattr_set_again_result.changed" \ No newline at end of file
diff --git a/test/integration/targets/xattr/tasks/setup.yml b/test/integration/targets/xattr/tasks/setup.yml
new file mode 100644
index 0000000000..4a0150e113
--- /dev/null
+++ b/test/integration/targets/xattr/tasks/setup.yml
@@ -0,0 +1,10 @@
+- name: Install
+ package:
+ name: attr
+ state: installed
+ become: true
+
+- name: Create file
+ file:
+ path: "{{ test_file }}"
+ state: touch \ No newline at end of file