mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-25 20:01:26 -07:00
Is changed (#427)
* Refactor tests to use "is" and "is not" changed * Refactor tests to use is succeeded or is failed * Reformat indentation * Add filter "bool" to prevent issues
This commit is contained in:
parent
61586ae4cc
commit
0a68bb270f
20 changed files with 194 additions and 188 deletions
|
@ -18,8 +18,8 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.executed_queries == ['CREATE DATABASE {{ test_db }}']
|
||||
- result is changed
|
||||
- result.executed_queries == ['CREATE DATABASE {{ test_db }}']
|
||||
|
||||
- name: Create {{ test_table1 }}
|
||||
mysql_query:
|
||||
|
@ -30,8 +30,8 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.executed_queries == ['CREATE TABLE {{ test_table1 }} (id int)']
|
||||
- result is changed
|
||||
- result.executed_queries == ['CREATE TABLE {{ test_table1 }} (id int)']
|
||||
|
||||
- name: Insert test data
|
||||
mysql_query:
|
||||
|
@ -45,9 +45,9 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.rowcount == [2, 1]
|
||||
- result.executed_queries == ['INSERT INTO {{ test_table1 }} VALUES (1), (2)', 'INSERT INTO {{ test_table1 }} VALUES (3)']
|
||||
- result is changed
|
||||
- result.rowcount == [2, 1]
|
||||
- result.executed_queries == ['INSERT INTO {{ test_table1 }} VALUES (1), (2)', 'INSERT INTO {{ test_table1 }} VALUES (3)']
|
||||
|
||||
- name: Check data in {{ test_table1 }}
|
||||
mysql_query:
|
||||
|
@ -58,12 +58,12 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.executed_queries == ['SELECT * FROM {{ test_table1 }}']
|
||||
- result.rowcount == [3]
|
||||
- result.query_result[0][0].id == 1
|
||||
- result.query_result[0][1].id == 2
|
||||
- result.query_result[0][2].id == 3
|
||||
- result is not changed
|
||||
- result.executed_queries == ['SELECT * FROM {{ test_table1 }}']
|
||||
- result.rowcount == [3]
|
||||
- result.query_result[0][0].id == 1
|
||||
- result.query_result[0][1].id == 2
|
||||
- result.query_result[0][2].id == 3
|
||||
|
||||
- name: Check data in {{ test_table1 }} using positional args
|
||||
mysql_query:
|
||||
|
@ -76,10 +76,10 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.executed_queries == ["SELECT * FROM {{ test_table1 }} WHERE id = 1"]
|
||||
- result.rowcount == [1]
|
||||
- result.query_result[0][0].id == 1
|
||||
- result is not changed
|
||||
- result.executed_queries == ["SELECT * FROM {{ test_table1 }} WHERE id = 1"]
|
||||
- result.rowcount == [1]
|
||||
- result.query_result[0][0].id == 1
|
||||
|
||||
- name: Check data in {{ test_table1 }} using named args
|
||||
mysql_query:
|
||||
|
@ -92,10 +92,10 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.executed_queries == ["SELECT * FROM {{ test_table1 }} WHERE id = 1"]
|
||||
- result.rowcount == [1]
|
||||
- result.query_result[0][0].id == 1
|
||||
- result is not changed
|
||||
- result.executed_queries == ["SELECT * FROM {{ test_table1 }} WHERE id = 1"]
|
||||
- result.rowcount == [1]
|
||||
- result.query_result[0][0].id == 1
|
||||
|
||||
- name: Update data in {{ test_table1 }}
|
||||
mysql_query:
|
||||
|
@ -109,9 +109,9 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.executed_queries == ['UPDATE {{ test_table1 }} SET id = 0 WHERE id = 1']
|
||||
- result.rowcount == [1]
|
||||
- result is changed
|
||||
- result.executed_queries == ['UPDATE {{ test_table1 }} SET id = 0 WHERE id = 1']
|
||||
- result.rowcount == [1]
|
||||
|
||||
- name: Check the prev update - row with value 1 does not exist anymore
|
||||
mysql_query:
|
||||
|
@ -124,9 +124,9 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.executed_queries == ['SELECT * FROM {{ test_table1 }} WHERE id = 1']
|
||||
- result.rowcount == [0]
|
||||
- result is not changed
|
||||
- result.executed_queries == ['SELECT * FROM {{ test_table1 }} WHERE id = 1']
|
||||
- result.rowcount == [0]
|
||||
|
||||
- name: Check the prev update - row with value - exist
|
||||
mysql_query:
|
||||
|
@ -139,9 +139,9 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.executed_queries == ['SELECT * FROM {{ test_table1 }} WHERE id = 0']
|
||||
- result.rowcount == [1]
|
||||
- result is not changed
|
||||
- result.executed_queries == ['SELECT * FROM {{ test_table1 }} WHERE id = 0']
|
||||
- result.rowcount == [1]
|
||||
|
||||
- name: Update data in {{ test_table1 }} again
|
||||
mysql_query:
|
||||
|
@ -155,9 +155,9 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.executed_queries == ['UPDATE {{ test_table1 }} SET id = 0 WHERE id = 1']
|
||||
- result.rowcount == [0]
|
||||
- result is not changed
|
||||
- result.executed_queries == ['UPDATE {{ test_table1 }} SET id = 0 WHERE id = 1']
|
||||
- result.rowcount == [0]
|
||||
|
||||
- name: Delete data from {{ test_table1 }}
|
||||
mysql_query:
|
||||
|
@ -170,9 +170,9 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.executed_queries == ['DELETE FROM {{ test_table1 }} WHERE id = 0', 'SELECT * FROM {{ test_table1 }} WHERE id = 0']
|
||||
- result.rowcount == [1, 0]
|
||||
- result is changed
|
||||
- result.executed_queries == ['DELETE FROM {{ test_table1 }} WHERE id = 0', 'SELECT * FROM {{ test_table1 }} WHERE id = 0']
|
||||
- result.rowcount == [1, 0]
|
||||
|
||||
- name: Delete data from {{ test_table1 }} again
|
||||
mysql_query:
|
||||
|
@ -183,9 +183,9 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.executed_queries == ['DELETE FROM {{ test_table1 }} WHERE id = 0']
|
||||
- result.rowcount == [0]
|
||||
- result is not changed
|
||||
- result.executed_queries == ['DELETE FROM {{ test_table1 }} WHERE id = 0']
|
||||
- result.rowcount == [0]
|
||||
|
||||
- name: Truncate {{ test_table1 }}
|
||||
mysql_query:
|
||||
|
@ -198,9 +198,9 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.executed_queries == ['TRUNCATE {{ test_table1 }}', 'SELECT * FROM {{ test_table1 }}']
|
||||
- result.rowcount == [0, 0]
|
||||
- result is changed
|
||||
- result.executed_queries == ['TRUNCATE {{ test_table1 }}', 'SELECT * FROM {{ test_table1 }}']
|
||||
- result.rowcount == [0, 0]
|
||||
|
||||
- name: Rename {{ test_table1 }}
|
||||
mysql_query:
|
||||
|
@ -211,9 +211,9 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.executed_queries == ['RENAME TABLE {{ test_table1 }} TO {{ test_table2 }}']
|
||||
- result.rowcount == [0]
|
||||
- result is changed
|
||||
- result.executed_queries == ['RENAME TABLE {{ test_table1 }} TO {{ test_table2 }}']
|
||||
- result.rowcount == [0]
|
||||
|
||||
- name: Check the prev rename
|
||||
mysql_query:
|
||||
|
@ -225,7 +225,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result.failed == true
|
||||
- result is failed
|
||||
|
||||
- name: Check the prev rename
|
||||
mysql_query:
|
||||
|
@ -236,7 +236,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result.rowcount == [0]
|
||||
- result.rowcount == [0]
|
||||
|
||||
- name: Create {{ test_table3 }}
|
||||
mysql_query:
|
||||
|
@ -259,7 +259,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result.rowcount == [2]
|
||||
- result.rowcount == [2]
|
||||
|
||||
- name: Pass wrong query type
|
||||
mysql_query:
|
||||
|
@ -271,8 +271,8 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is failed
|
||||
- result.msg is search('the query option value must be a string or list')
|
||||
- result is failed
|
||||
- result.msg is search('the query option value must be a string or list')
|
||||
|
||||
- name: Pass wrong query element
|
||||
mysql_query:
|
||||
|
@ -286,8 +286,8 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is failed
|
||||
- result.msg is search('the elements in query list must be strings')
|
||||
- result is failed
|
||||
- result.msg is search('the elements in query list must be strings')
|
||||
|
||||
- name: Create {{ test_table4 }}
|
||||
mysql_query:
|
||||
|
@ -305,8 +305,8 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.rowcount == [1]
|
||||
- result is changed
|
||||
- result.rowcount == [1]
|
||||
|
||||
- name: Replace test data
|
||||
mysql_query:
|
||||
|
@ -318,8 +318,8 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.rowcount == [2]
|
||||
- result is changed
|
||||
- result.rowcount == [2]
|
||||
|
||||
# Issue https://github.com/ansible-collections/community.mysql/issues/268
|
||||
- name: Create table
|
||||
|
@ -341,17 +341,17 @@
|
|||
# Issue https://github.com/ansible-collections/community.mysql/issues/268
|
||||
- assert:
|
||||
that:
|
||||
# PyMySQL driver throws a warning, so the following is correct
|
||||
- result is not changed
|
||||
# PyMySQL driver throws a warning, so the following is correct
|
||||
- result is not changed
|
||||
when: connector_name is search('pymysql')
|
||||
|
||||
# Issue https://github.com/ansible-collections/community.mysql/issues/268
|
||||
- assert:
|
||||
that:
|
||||
# mysqlclient driver throws nothing, so it's impossible to figure out
|
||||
# if the state was changed or not.
|
||||
# We assume that it was for DDL queryes by default in the code
|
||||
- result is changed
|
||||
# mysqlclient driver throws nothing, so it's impossible to figure out
|
||||
# if the state was changed or not.
|
||||
# We assume that it was for DDL queryes by default in the code
|
||||
- result is changed
|
||||
when: connector_name is search('mysqlclient')
|
||||
|
||||
- name: Drop db {{ test_db }}
|
||||
|
@ -362,5 +362,5 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.executed_queries == ['DROP DATABASE {{ test_db }}']
|
||||
- result is changed
|
||||
- result.executed_queries == ['DROP DATABASE {{ test_db }}']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue