diff options
author | Matt Clay <mclay@redhat.com> | 2021-06-17 15:41:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-17 15:41:09 +0200 |
commit | 5e65d9834ba5852f1915c360a24f843b46d2d8bc (patch) | |
tree | 294ed832b56872487f7b7689b14751428c591640 /test/integration/targets/tempfile | |
parent | slurp - improve error code and test coverage (#75038) (diff) | |
download | ansible-5e65d9834ba5852f1915c360a24f843b46d2d8bc.tar.xz ansible-5e65d9834ba5852f1915c360a24f843b46d2d8bc.zip |
tempfile - Remove unnecessary conditional. (#75039)
Also add integration tests for 100% code coverage.
Diffstat (limited to 'test/integration/targets/tempfile')
-rw-r--r-- | test/integration/targets/tempfile/aliases | 1 | ||||
-rw-r--r-- | test/integration/targets/tempfile/meta/main.yml | 2 | ||||
-rw-r--r-- | test/integration/targets/tempfile/tasks/main.yml | 63 |
3 files changed, 66 insertions, 0 deletions
diff --git a/test/integration/targets/tempfile/aliases b/test/integration/targets/tempfile/aliases new file mode 100644 index 0000000000..a6dafcf8cd --- /dev/null +++ b/test/integration/targets/tempfile/aliases @@ -0,0 +1 @@ +shippable/posix/group1 diff --git a/test/integration/targets/tempfile/meta/main.yml b/test/integration/targets/tempfile/meta/main.yml new file mode 100644 index 0000000000..1810d4bec9 --- /dev/null +++ b/test/integration/targets/tempfile/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_remote_tmp_dir diff --git a/test/integration/targets/tempfile/tasks/main.yml b/test/integration/targets/tempfile/tasks/main.yml new file mode 100644 index 0000000000..2d783e6f9a --- /dev/null +++ b/test/integration/targets/tempfile/tasks/main.yml @@ -0,0 +1,63 @@ +- name: Create a temporary file with defaults + tempfile: + register: temp_file_default + +- name: Create a temporary directory with defaults + tempfile: + state: directory + register: temp_dir_default + +- name: Create a temporary file with optional parameters + tempfile: + path: "{{ remote_tmp_dir }}" + prefix: hello. + suffix: .goodbye + register: temp_file_options + +- name: Create a temporary directory with optional parameters + tempfile: + state: directory + path: "{{ remote_tmp_dir }}" + prefix: hello. + suffix: .goodbye + register: temp_dir_options + +- name: Create a temporary file in a non-existent directory + tempfile: + path: "{{ remote_tmp_dir }}/does_not_exist" + register: temp_file_non_existent_path + ignore_errors: yes + +- name: Create a temporary directory in a non-existent directory + tempfile: + state: directory + path: "{{ remote_tmp_dir }}/does_not_exist" + register: temp_dir_non_existent_path + ignore_errors: yes + +- name: Check results + assert: + that: + - temp_file_default is changed + - temp_file_default.state == 'file' + - temp_file_default.path | basename | split('.') | first == 'ansible' + + - temp_dir_default is changed + - temp_dir_default.state == 'directory' + - temp_dir_default.path | basename | split('.') | first == 'ansible' + + - temp_file_options is changed + - temp_file_options.state == 'file' + - temp_file_options.path.startswith(remote_tmp_dir) + - temp_file_options.path | basename | split('.') | first == 'hello' + - temp_file_options.path | basename | split('.') | last == 'goodbye' + + - temp_dir_options is changed + - temp_dir_options.state == 'directory' + - temp_dir_options.path.startswith(remote_tmp_dir) + - temp_dir_options.path | basename | split('.') | first == 'hello' + - temp_dir_options.path | basename | split('.') | last == 'goodbye' + + - temp_file_non_existent_path is failed + + - temp_dir_non_existent_path is failed |