Add some more test coverage for unarchive (#68272)
* Add some more test coverage for unarchive This moves over (and slightly extends) coverage which was found in incidental_flatpak_remote. Signed-off-by: Rick Elrod <rick@elrod.me> * add a group for testing too, user creation does not mean group creation on all platforms Signed-off-by: Rick Elrod <rick@elrod.me> * update the test group assert Signed-off-by: Rick Elrod <rick@elrod.me> * Fix style Signed-off-by: Rick Elrod <rick@elrod.me> * block/always Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
parent
11e678b1b0
commit
0651e1c25f
1 changed files with 108 additions and 0 deletions
|
@ -174,6 +174,114 @@
|
||||||
- name: remove our tar.gz unarchive destination
|
- name: remove our tar.gz unarchive destination
|
||||||
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=absent
|
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=absent
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Create a group to chown to
|
||||||
|
group:
|
||||||
|
name: testgroup
|
||||||
|
|
||||||
|
- name: Create a user to chown to
|
||||||
|
user:
|
||||||
|
name: testuser
|
||||||
|
groups:
|
||||||
|
- testgroup
|
||||||
|
|
||||||
|
- name: create our tar.gz unarchive destination for chown
|
||||||
|
file:
|
||||||
|
path: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: unarchive a tar.gz file with owner and group set to the above user
|
||||||
|
unarchive:
|
||||||
|
src: "{{remote_tmp_dir}}/test-unarchive.tar.gz"
|
||||||
|
dest: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
|
||||||
|
remote_src: yes
|
||||||
|
owner: testuser
|
||||||
|
group: testgroup
|
||||||
|
register: unarchive02e
|
||||||
|
|
||||||
|
- name: Stat a file in the directory we unarchived to
|
||||||
|
stat:
|
||||||
|
path: "{{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt"
|
||||||
|
register: unarchive02e_file_stat
|
||||||
|
|
||||||
|
- name: verify results
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- unarchive02e is changed
|
||||||
|
- unarchive02e_file_stat.stat.exists
|
||||||
|
- unarchive02e_file_stat.stat.pw_name == 'testuser'
|
||||||
|
- unarchive02e_file_stat.stat.gr_name == 'testgroup'
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove testuser
|
||||||
|
user:
|
||||||
|
name: testuser
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Remove testgroup
|
||||||
|
group:
|
||||||
|
name: testgroup
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
# tgz: --keep-newer
|
||||||
|
- name: create our tar.gz unarchive destination for keep-newer
|
||||||
|
file:
|
||||||
|
path: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Create a newer file that we would replace
|
||||||
|
copy:
|
||||||
|
dest: "{{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt"
|
||||||
|
content: boo
|
||||||
|
|
||||||
|
- name: unarchive a tar.gz file but avoid overwriting newer files (keep_newer=true)
|
||||||
|
unarchive:
|
||||||
|
src: "{{remote_tmp_dir}}/test-unarchive.tar.gz"
|
||||||
|
dest: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
|
||||||
|
remote_src: yes
|
||||||
|
keep_newer: true
|
||||||
|
register: unarchive02f
|
||||||
|
|
||||||
|
- name: Make sure the file still contains 'boo'
|
||||||
|
shell: cat {{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt
|
||||||
|
register: unarchive02f_cat
|
||||||
|
|
||||||
|
- name: remove our tar.gz unarchive destination
|
||||||
|
file:
|
||||||
|
path: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: create our tar.gz unarchive destination for keep-newer (take 2)
|
||||||
|
file:
|
||||||
|
path: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: unarchive a tar.gz file and overwrite newer files (keep_newer=false)
|
||||||
|
unarchive:
|
||||||
|
src: "{{remote_tmp_dir}}/test-unarchive.tar.gz"
|
||||||
|
dest: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
|
||||||
|
remote_src: yes
|
||||||
|
keep_newer: false
|
||||||
|
register: unarchive02g
|
||||||
|
|
||||||
|
- name: Make sure the file still contains 'boo'
|
||||||
|
shell: cat {{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt
|
||||||
|
register: unarchive02g_cat
|
||||||
|
|
||||||
|
- name: remove our tar.gz unarchive destination
|
||||||
|
file:
|
||||||
|
path: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: verify results
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- unarchive02f is changed
|
||||||
|
- unarchive02f_cat.stdout == 'boo'
|
||||||
|
- unarchive02g is changed
|
||||||
|
- unarchive02g_cat.stdout != 'boo'
|
||||||
|
|
||||||
|
# Zip
|
||||||
- name: create our zip unarchive destination
|
- name: create our zip unarchive destination
|
||||||
file: path={{remote_tmp_dir}}/test-unarchive-zip state=directory
|
file: path={{remote_tmp_dir}}/test-unarchive-zip state=directory
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue