diff --git a/tests/integration/targets/gcp_storage_object/defaults/main.yml b/tests/integration/targets/gcp_storage_object/defaults/main.yml index aa87a2a..ba66644 100644 --- a/tests/integration/targets/gcp_storage_object/defaults/main.yml +++ b/tests/integration/targets/gcp_storage_object/defaults/main.yml @@ -1,3 +1,2 @@ --- -# defaults file -resource_name: '{{resource_prefix}}' +resource_name: "{{ resource_prefix }}" diff --git a/tests/integration/targets/gcp_storage_object/tasks/main.yml b/tests/integration/targets/gcp_storage_object/tasks/main.yml new file mode 100644 index 0000000..2bbfde6 --- /dev/null +++ b/tests/integration/targets/gcp_storage_object/tasks/main.yml @@ -0,0 +1,78 @@ +--- +# Pre-test setup +- name: create a temp file for uploading + tempfile: + state: file + register: upload_temp +- name: create a temp file for downloading + tempfile: + state: file + register: download_temp +- name: put content in the tempfile + copy: + content: "Ansible GCS test file" + dest: "{{ upload_temp.path }}" +- name: create a bucket + google.cloud.gcp_storage_bucket: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: bucket +#---------------------------------------------------------- +- name: upload the object to gcs + google.cloud.gcp_storage_object: + action: 'upload' + bucket: "{{ bucket.name }}" + src: "{{ upload_temp.path }}" + dest: "ansible/{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +# ---------------------------------------------------------------------------- +- name: download the object to disk + google.cloud.gcp_storage_object: + action: 'download' + bucket: "{{ bucket.name }}" + src: "ansible/{{ resource_name }}" + dest: "{{ download_temp.path }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +# ---------------------------------------------------------------------------- +- name: delete the object + google.cloud.gcp_storage_object: + action: 'delete' + bucket: "{{ bucket.name }}" + src: "ansible/{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +# ---------------------------------------------------------------------------- +- name: delete the bucket + google.cloud.gcp_storage_bucket: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: bucket