]> git.immae.eu Git - github/fretlink/ansible-clever.git/commitdiff
add a test for `noop-if-up-to-date`
authorClement Delafargue <clement.delafargue@fretlink.com>
Tue, 30 Jun 2020 07:33:18 +0000 (09:33 +0200)
committerClement Delafargue <clement.delafargue@fretlink.com>
Tue, 30 Jun 2020 14:26:19 +0000 (16:26 +0200)
It makes sure `clever deploy` is _not_ called if the application
is up-to-date on clever cloud

tests/test-all.yml
tests/test-noop-deploy.yml [new file with mode: 0644]

index 64eb239d58a7cec672d2ea5137cf94f78645353a..145b16d2b1f867d6aa0453dc012779b94ff95f11 100644 (file)
@@ -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 (file)
index 0000000..13eed20
--- /dev/null
@@ -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 }}"