forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add integration tests for xattr module (ansible#24947)
* add integration tests for xattr module * fix whitespace
- Loading branch information
1 parent
8d8cfb5
commit 25aac61
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
destructive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test_file: ~/foo.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- name: Install | ||
package: | ||
name: attr | ||
state: installed | ||
become: true | ||
|
||
- name: Create file | ||
file: | ||
path: "{{ test_file }}" | ||
state: touch |