From: Clement Delafargue Date: Tue, 30 Jun 2020 13:46:41 +0000 (+0200) Subject: fix(tests): use `! grep` instead of `grep -v` X-Git-Tag: v2.7~1^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=db630aaa8b261503076eb7320ee3cee5a5582be8;p=github%2Ffretlink%2Fansible-clever.git fix(tests): use `! grep` instead of `grep -v` `grep -v` makes sure a file contains other lines than the one that matched. This is different from `! grep` which makes sure the file does not contain a line that matched. --- diff --git a/tests/test-configure-app.yml b/tests/test-configure-app.yml index 15987fd..e9861a2 100644 --- a/tests/test-configure-app.yml +++ b/tests/test-configure-app.yml @@ -21,7 +21,7 @@ msg: "CC_RUN_COMMAND env variable should not be present in the environment dict" when: clever_env.CC_RUN_COMMAND is defined - name: Check stubbed commands - command: "{{ item.cmd }}" + shell: "{{ item.cmd }}" ignore_errors: true vars: display: "{{ item.display }}" @@ -34,7 +34,7 @@ display: "Expected 'clever domain' command to be called" - cmd: "grep drain ../clever-commands" display: "Expected 'clever drain' command to be called" - - cmd: "grep -v restart ../clever-commands" + - cmd: "! grep restart ../clever-commands" display: "Expected 'clever restart' command to NOT be called" register: tests_results - name: show results diff --git a/tests/test-restart-app.yml b/tests/test-restart-app.yml index 4c13a14..bc880a8 100644 --- a/tests/test-restart-app.yml +++ b/tests/test-restart-app.yml @@ -15,16 +15,16 @@ clever_restart_only: true post_tasks: - name: Check stubbed commands - command: "{{ item.cmd }}" + shell: "{{ item.cmd }}" ignore_errors: true vars: display: "{{ item.display }}" with_list: - cmd: "grep restart ../clever-commands" display: "Expected 'clever restart' command to be called" - - cmd: "grep -v deploy ../clever-commands" + - cmd: "! grep deploy ../clever-commands" display: "Expected 'clever deploy' command to NOT be called" - - cmd: "grep -v scale ../clever-commands" + - cmd: "! grep scale ../clever-commands" display: "Expected 'clever scale' command to NOT be called" register: tests_results - name: show results diff --git a/tests/test-scalability.yml b/tests/test-scalability.yml index 6bb90d2..258beaf 100644 --- a/tests/test-scalability.yml +++ b/tests/test-scalability.yml @@ -29,7 +29,7 @@ flavors: { min: "nano", max: "XS" } post_tasks: - name: Check stubbed commands - command: "{{ item.cmd }}" + shell: "{{ item.cmd }}" ignore_errors: true vars: display: "{{ item.display }}" @@ -38,7 +38,7 @@ display: "Expected 'clever deploy' command to be called" - cmd: "grep scale ../clever-commands" display: "Expected 'clever scale' command to be called" - - cmd: "grep -v restart ../clever-commands" + - cmd: "! grep restart ../clever-commands" display: "Expected 'clever restart' command to NOT be called" register: tests_results - name: show results