From: Clement Delafargue Date: Tue, 30 Jun 2020 07:33:18 +0000 (+0200) Subject: add a test for `noop-if-up-to-date` X-Git-Tag: v2.7~1^2~2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=75a2a2fbcc31766e2debab1c8bd5cdce42f14fb7;p=github%2Ffretlink%2Fansible-clever.git add a test for `noop-if-up-to-date` It makes sure `clever deploy` is _not_ called if the application is up-to-date on clever cloud --- diff --git a/tests/test-all.yml b/tests/test-all.yml index 64eb239..145b16d 100644 --- a/tests/test-all.yml +++ b/tests/test-all.yml @@ -2,5 +2,6 @@ - import_playbook: ./test-simple-app.yml - import_playbook: ./test-configure-app.yml - import_playbook: ./test-haskell-app.yml +- import_playbook: ./test-noop-deploy.yml - import_playbook: ./test-scalability.yml - import_playbook: ./test-restart-app.yml diff --git a/tests/test-noop-deploy.yml b/tests/test-noop-deploy.yml new file mode 100644 index 0000000..13eed20 --- /dev/null +++ b/tests/test-noop-deploy.yml @@ -0,0 +1,35 @@ +--- +- name: Do nothing if the app is up-to-date on clever + hosts: localhost + remote_user: root + pre_tasks: + - file: + state: absent + path: ../clever-commands + roles: + - role: clever + vars: + clever_token: 123abc + clever_secret: cba321 + clever_app: app_00000000-0000-0000-0000-000000000000 + environment: + PRETEND_REMOTE_COMMIT: aaa000aaa000aaa000aaa000aaa000aaa000aaa0 + post_tasks: + - name: Check stubbed commands + shell: "{{ item.cmd }}" + ignore_errors: true + with_list: + - cmd: "! grep deploy ../clever-commands" + display: "Expected 'clever deploy' command to NOT be called" + vars: + display: "{{ item.display }}" + register: tests_results + - name: show results + debug: + msg: + - "failed_results: {{ failed_results }}" + - "success_results: {{ success_results }}" + failed_when: tests_results is failed + vars: + failed_results: "{{ tests_results.results | selectattr('failed') | map(attribute='item.display') | list }}" + success_results: "{{ tests_results.results | rejectattr('failed') | map(attribute='item.display') | list }}"