From e412aa5142d40eee1979db8ca95d8bae335772c3 Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Fri, 20 Jan 2023 18:19:29 +0100 Subject: [PATCH] Add clean up in "always" phase of the block Because our tests use --retry-on-error, and the first thing the test does is to try to create the database. We must cleanup otherwise if there is a retry, it will throw a misleading "database already exists" error. --- .../targets/test_mysql_query/tasks/mysql_query_initial.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/integration/targets/test_mysql_query/tasks/mysql_query_initial.yml b/tests/integration/targets/test_mysql_query/tasks/mysql_query_initial.yml index 4b9500b..d97c554 100644 --- a/tests/integration/targets/test_mysql_query/tasks/mysql_query_initial.yml +++ b/tests/integration/targets/test_mysql_query/tasks/mysql_query_initial.yml @@ -390,3 +390,10 @@ that: - result is changed - result.executed_queries == ['DROP DATABASE {{ test_db }}'] + + always: + + - name: Clean up test_db + mysql_query: + <<: *mysql_params + query: 'DROP DATABASE IF EXISTS {{ test_db }}'