Refactor tests to use "is" and "is not" changed

This commit is contained in:
Laurent Indermuehle 2022-08-22 14:28:46 +02:00
commit e3a2b22fdd
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
18 changed files with 128 additions and 122 deletions

View file

@ -56,7 +56,7 @@
- name: assert successful completion of create database using check_mode since databases does not exist prior - name: assert successful completion of create database using check_mode since databases does not exist prior
assert: assert:
that: that:
- check_mode_result.changed == true - check_mode_result is changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -87,7 +87,7 @@
- name: assert successful completion of create database - name: assert successful completion of create database
assert: assert:
that: that:
- result.changed == true - result is changed
- result.db_list == ['{{ db1_name }}', '{{ db2_name }}', '{{ db3_name }}'] - result.db_list == ['{{ db1_name }}', '{{ db2_name }}', '{{ db3_name }}']
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
@ -120,7 +120,7 @@
- name: assert that recreation of existing databases does not make change (since recreated using check mode) - name: assert that recreation of existing databases does not make change (since recreated using check mode)
assert: assert:
that: that:
- check_mode_result.changed == false - check_mode_result is not changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -151,7 +151,7 @@
- name: assert that recreation of existing databases does not make change - name: assert that recreation of existing databases does not make change
assert: assert:
that: that:
- result.changed == false - result is not changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -180,7 +180,7 @@
- name: assert successful completion of deleting database - name: assert successful completion of deleting database
assert: assert:
that: that:
- result.changed == true - result is changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -212,7 +212,7 @@
- name: assert successful completion of recreation of partially existing database using check mode - name: assert successful completion of recreation of partially existing database using check mode
assert: assert:
that: that:
- check_mode_result.changed == true - check_mode_result is changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -243,7 +243,7 @@
- name: assert successful completion of create database - name: assert successful completion of create database
assert: assert:
that: that:
- result.changed == true - result is changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -284,7 +284,7 @@
- name: assert successful completion of dump operation using check mode - name: assert successful completion of dump operation using check mode
assert: assert:
that: that:
- check_mode_dump_result.changed == true - check_mode_dump_result is changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -401,7 +401,7 @@
- name: assert successful completion of dump operation - name: assert successful completion of dump operation
assert: assert:
that: that:
- dump_result.changed == true - dump_result is changed
- dump_result.db_list == ['{{ db1_name }}', '{{ db2_name }}', '{{ db3_name }}'] - dump_result.db_list == ['{{ db1_name }}', '{{ db2_name }}', '{{ db3_name }}']
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
@ -451,7 +451,7 @@
- name: assert successful completion of dump operation - name: assert successful completion of dump operation
assert: assert:
that: that:
- dump_result.changed == true - dump_result is changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -491,7 +491,7 @@
- name: assert successful completion of delete databases which already exists using check mode - name: assert successful completion of delete databases which already exists using check mode
assert: assert:
that: that:
- check_mode_result.changed == true - check_mode_result is changed
- name: run command to test state=absent for a database name - name: run command to test state=absent for a database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -520,7 +520,7 @@
- name: assert successful completion of deleting database - name: assert successful completion of deleting database
assert: assert:
that: that:
- result.changed == true - result is changed
- result.db_list == ['{{ db2_name }}', '{{ db3_name }}'] - result.db_list == ['{{ db2_name }}', '{{ db3_name }}']
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
@ -551,7 +551,7 @@
- name: assert that deletion of non existing databases does not make change (using check mode) - name: assert that deletion of non existing databases does not make change (using check mode)
assert: assert:
that: that:
- check_mode_result.changed == false - check_mode_result is not changed
- name: run command to test state=absent for a database name - name: run command to test state=absent for a database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -580,7 +580,7 @@
- name: assert that deletion of non existing databases does not make change - name: assert that deletion of non existing databases does not make change
assert: assert:
that: that:
- result.changed == false - result is not changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""
@ -612,7 +612,7 @@
- name: assert successful completion of deleting database - name: assert successful completion of deleting database
assert: assert:
that: that:
- result.changed == true - result is changed
- name: run command to list databases like specified database name - name: run command to list databases like specified database name
command: "{{ mysql_command }} \"-e show databases like 'database%'\"" command: "{{ mysql_command }} \"-e show databases like 'database%'\""

View file

@ -159,7 +159,7 @@
- name: assert successful completion of dump operation (with multiple databases in list form) via check mode - name: assert successful completion of dump operation (with multiple databases in list form) via check mode
assert: assert:
that: that:
- "dump_result.changed == true" - dump_result is changed
- name: database dump file2 should not exist - name: database dump file2 should not exist
stat: stat:
@ -187,7 +187,7 @@
- name: assert successful completion of dump operation (with multiple databases in list form) - name: assert successful completion of dump operation (with multiple databases in list form)
assert: assert:
that: that:
- "dump_result2.changed == true" - dump_result2 is changed
- name: state dump - dump file2 should exist - name: state dump - dump file2 should exist
file: file:
@ -249,7 +249,7 @@
- name: assert output message restored a database from dump file1 - name: assert output message restored a database from dump file1
assert: assert:
that: that:
- "import_result.changed == true" - import_result is changed
- name: remove database - name: remove database
mysql_db: mysql_db:
@ -284,7 +284,7 @@
- name: assert output message restored a database from dump file2 (check mode) - name: assert output message restored a database from dump file2 (check mode)
assert: assert:
that: that:
- "check_import_result.changed == true" - check_import_result is changed
- name: run command to list databases - name: run command to list databases
command: "{{ mysql_command }} \"-e show databases like 'data%'\"" command: "{{ mysql_command }} \"-e show databases like 'data%'\""
@ -309,7 +309,7 @@
- name: assert output message restored a database from dump file2 - name: assert output message restored a database from dump file2
assert: assert:
that: that:
- import_result2.changed == true - import_result2 is changed
- import_result2.db_list == ['{{ db_name2 }}'] - import_result2.db_list == ['{{ db_name2 }}']
- name: run command to list databases - name: run command to list databases
@ -335,7 +335,7 @@
- name: assert output message backup the database - name: assert output message backup the database
assert: assert:
that: that:
- "result.changed == true" - result is changed
- "result.db =='{{ db_name }}'" - "result.db =='{{ db_name }}'"
# - name: assert database was backed up successfully # - name: assert database was backed up successfully
@ -364,7 +364,7 @@
- name: assert output message restore the database - name: assert output message restore the database
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: select data from table employee - name: select data from table employee
command: "{{ mysql_command }} {{ db_name }} \"-e select * from employee\"" command: "{{ mysql_command }} {{ db_name }} \"-e select * from employee\""

View file

@ -196,7 +196,7 @@
- name: assert output message that database was created - name: assert output message that database was created
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: run command to test database was created using user1 - name: run command to test database was created using user1
command: "{{ mysql_command }} -e \"show databases like '{{ db_user1 | regex_replace(\"([%_\\\\])\", \"\\\\\\1\") }}'\"" command: "{{ mysql_command }} -e \"show databases like '{{ db_user1 | regex_replace(\"([%_\\\\])\", \"\\\\\\1\") }}'\""

View file

@ -47,7 +47,7 @@
- assert: - assert:
that: that:
- result.changed == false - result is not changed
- "mysql_version in result.version.full or mariadb_version in result.version.full" - "mysql_version in result.version.full or mariadb_version in result.version.full"
- result.settings != {} - result.settings != {}
- result.global_status != {} - result.global_status != {}
@ -66,7 +66,7 @@
- assert: - assert:
that: that:
- result.changed == false - result is not changed
- result.version != {} - result.version != {}
# Remove cred files # Remove cred files
@ -86,8 +86,8 @@
- assert: - assert:
that: that:
- result.changed == false - result is not changed
- result.version != {} - result.version != {}
# Test excluding # Test excluding
- name: Collect all info except settings and users - name: Collect all info except settings and users
@ -98,13 +98,13 @@
- assert: - assert:
that: that:
- result.changed == false - result is not changed
- result.version != {} - result.version != {}
- result.global_status != {} - result.global_status != {}
- result.databases != {} - result.databases != {}
- result.engines != {} - result.engines != {}
- result.settings is not defined - result.settings is not defined
- result.users is not defined - result.users is not defined
# Test including # Test including
- name: Collect info only about version and databases - name: Collect info only about version and databases
@ -117,13 +117,13 @@
- assert: - assert:
that: that:
- result.changed == false - result is not changed
- result.version != {} - result.version != {}
- result.databases != {} - result.databases != {}
- result.engines is not defined - result.engines is not defined
- result.settings is not defined - result.settings is not defined
- result.global_status is not defined - result.global_status is not defined
- result.users is not defined - result.users is not defined
# Test exclude_fields: db_size # Test exclude_fields: db_size
# 'unsupported' element is passed to check that an unsupported value # 'unsupported' element is passed to check that an unsupported value
@ -140,9 +140,9 @@
- assert: - assert:
that: that:
- result.changed == false - result is not changed
- result.databases != {} - result.databases != {}
- result.databases.mysql == {} - result.databases.mysql == {}
######################################################## ########################################################
# Issue #65727, empty databases must be in returned dict # Issue #65727, empty databases must be in returned dict
@ -163,9 +163,9 @@
# Check acme is in returned dict # Check acme is in returned dict
- assert: - assert:
that: that:
- result.changed == false - result is not changed
- result.databases.acme.size == 0 - result.databases.acme.size == 0
- result.databases.mysql != {} - result.databases.mysql != {}
- name: Collect info about databases excluding their sizes - name: Collect info about databases excluding their sizes
mysql_info: mysql_info:
@ -180,9 +180,9 @@
# Check acme is in returned dict # Check acme is in returned dict
- assert: - assert:
that: that:
- result.changed == false - result is not changed
- result.databases.acme == {} - result.databases.acme == {}
- result.databases.mysql == {} - result.databases.mysql == {}
- name: Remove acme database - name: Remove acme database
mysql_db: mysql_db:

View file

@ -18,8 +18,8 @@
- assert: - assert:
that: that:
- result is changed - result is changed
- result.executed_queries == ['CREATE DATABASE {{ test_db }}'] - result.executed_queries == ['CREATE DATABASE {{ test_db }}']
- name: Create {{ test_table1 }} - name: Create {{ test_table1 }}
mysql_query: mysql_query:
@ -30,8 +30,8 @@
- assert: - assert:
that: that:
- result is changed - result is changed
- result.executed_queries == ['CREATE TABLE {{ test_table1 }} (id int)'] - result.executed_queries == ['CREATE TABLE {{ test_table1 }} (id int)']
- name: Insert test data - name: Insert test data
mysql_query: mysql_query:
@ -45,9 +45,9 @@
- assert: - assert:
that: that:
- result is changed - result is changed
- result.rowcount == [2, 1] - result.rowcount == [2, 1]
- result.executed_queries == ['INSERT INTO {{ test_table1 }} VALUES (1), (2)', 'INSERT INTO {{ test_table1 }} VALUES (3)'] - result.executed_queries == ['INSERT INTO {{ test_table1 }} VALUES (1), (2)', 'INSERT INTO {{ test_table1 }} VALUES (3)']
- name: Check data in {{ test_table1 }} - name: Check data in {{ test_table1 }}
mysql_query: mysql_query:
@ -305,8 +305,8 @@
- assert: - assert:
that: that:
- result is changed - result is changed
- result.rowcount == [1] - result.rowcount == [1]
- name: Replace test data - name: Replace test data
mysql_query: mysql_query:
@ -318,8 +318,8 @@
- assert: - assert:
that: that:
- result is changed - result is changed
- result.rowcount == [2] - result.rowcount == [2]
# Issue https://github.com/ansible-collections/community.mysql/issues/268 # Issue https://github.com/ansible-collections/community.mysql/issues/268
- name: Create table - name: Create table
@ -341,17 +341,17 @@
# Issue https://github.com/ansible-collections/community.mysql/issues/268 # Issue https://github.com/ansible-collections/community.mysql/issues/268
- assert: - assert:
that: that:
# PyMySQL driver throws a warning, so the following is correct # PyMySQL driver throws a warning, so the following is correct
- result is not changed - result is not changed
when: connector_name is search('pymysql') when: connector_name is search('pymysql')
# Issue https://github.com/ansible-collections/community.mysql/issues/268 # Issue https://github.com/ansible-collections/community.mysql/issues/268
- assert: - assert:
that: that:
# mysqlclient driver throws nothing, so it's impossible to figure out # mysqlclient driver throws nothing, so it's impossible to figure out
# if the state was changed or not. # if the state was changed or not.
# We assume that it was for DDL queryes by default in the code # We assume that it was for DDL queryes by default in the code
- result is changed - result is changed
when: connector_name is search('mysqlclient') when: connector_name is search('mysqlclient')
- name: Drop db {{ test_db }} - name: Drop db {{ test_db }}
@ -362,5 +362,5 @@
- assert: - assert:
that: that:
- result is changed - result is changed
- result.executed_queries == ['DROP DATABASE {{ test_db }}'] - result.executed_queries == ['DROP DATABASE {{ test_db }}']

View file

@ -45,7 +45,7 @@
- name: Assert that there wasn't a change in permissions - name: Assert that there wasn't a change in permissions
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- name: Run command to show privileges for role (expect privileges in stdout) - name: Run command to show privileges for role (expect privileges in stdout)
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\"" command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\""
@ -69,7 +69,7 @@
- name: Assert that there was a change because permissions were/would be revoked on data1.* - name: Assert that there was a change because permissions were/would be revoked on data1.*
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Run command to show privileges for role (expect privileges in stdout) - name: Run command to show privileges for role (expect privileges in stdout)
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\"" command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\""
@ -100,7 +100,7 @@
- name: Assert that there was no change because invalid permissions are ignored - name: Assert that there was no change because invalid permissions are ignored
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- name: Run command to show privileges for role (expect privileges in stdout) - name: Run command to show privileges for role (expect privileges in stdout)
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\"" command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\""

View file

@ -43,4 +43,4 @@
- name: assert output message mysql user was created - name: assert output message mysql user was created
assert: assert:
that: that:
- "result.changed == true" - result is changed

View file

@ -28,7 +28,7 @@
- name: assert output message mysql user was created - name: assert output message mysql user was created
assert: assert:
that: that:
- "result.changed == true" - result is changed
- include: assert_user.yml user_name={{user_name_1}} - include: assert_user.yml user_name={{user_name_1}}
@ -45,7 +45,7 @@
- name: assert output message mysql user was removed - name: assert output message mysql user was removed
assert: assert:
that: that:
- "result.changed == true" - result is changed
# Test blank user removal # Test blank user removal
- name: create blank mysql user to be removed later - name: create blank mysql user to be removed later
@ -68,7 +68,7 @@
- name: assert changed is true for removing all blank users - name: assert changed is true for removing all blank users
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: remove blank mysql user with hosts=all (expect ok) - name: remove blank mysql user with hosts=all (expect ok)
mysql_user: mysql_user:
@ -82,7 +82,7 @@
- name: assert changed is true for removing all blank users - name: assert changed is true for removing all blank users
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- include: assert_no_user.yml user_name={{user_name_1}} - include: assert_no_user.yml user_name={{user_name_1}}
@ -109,7 +109,7 @@
- name: assert output message mysql user was created - name: assert output message mysql user was created
assert: assert:
that: that:
- "result.changed == true" - result is changed
- include: assert_user.yml user_name={{user_name_1}} - include: assert_user.yml user_name={{user_name_1}}
@ -126,7 +126,7 @@
- name: assert output message mysql user was removed - name: assert output message mysql user was removed
assert: assert:
that: that:
- "result.changed == true" - result is changed
# Test blank user removal # Test blank user removal
- name: create blank mysql user to be removed later - name: create blank mysql user to be removed later
@ -149,7 +149,7 @@
- name: assert changed is true for removing all blank users - name: assert changed is true for removing all blank users
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: remove blank mysql user with hosts=all (expect ok) - name: remove blank mysql user with hosts=all (expect ok)
mysql_user: mysql_user:
@ -163,6 +163,6 @@
- name: assert changed is true for removing all blank users - name: assert changed is true for removing all blank users
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- include: assert_no_user.yml user_name={{user_name_1}} - include: assert_no_user.yml user_name={{user_name_1}}

View file

@ -17,7 +17,9 @@
register: result register: result
- name: assert root password is changed - name: assert root password is changed
assert: { that: "result.changed == true" } assert:
that:
- result is changed
- name: Set root password again - name: Set root password again
mysql_user: mysql_user:
@ -31,7 +33,9 @@
register: result register: result
- name: Assert root password is not changed - name: Assert root password is not changed
assert: { that: "result.changed == false" } assert:
that:
- result is not changed
- name: Set root password again - name: Set root password again
mysql_user: mysql_user:

View file

@ -65,7 +65,9 @@
register: result register: result
- name: assert output message mysql user was not created - name: assert output message mysql user was not created
assert: { that: "result.changed == false" } assert:
that:
- result is not changed
# ============================================================ # ============================================================
# remove mysql user and verify user is removed from mysql database # remove mysql user and verify user is removed from mysql database
@ -81,7 +83,7 @@
- name: assert output message mysql user was removed - name: assert output message mysql user was removed
assert: assert:
that: that:
- "result.changed == true" - result is changed
- include: assert_no_user.yml user_name={{user_name_1}} - include: assert_no_user.yml user_name={{user_name_1}}
@ -99,7 +101,7 @@
- name: assert output message mysql user that does not exist - name: assert output message mysql user that does not exist
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- include: assert_no_user.yml user_name={{user_name_1}} - include: assert_no_user.yml user_name={{user_name_1}}

View file

@ -37,7 +37,7 @@
- name: assert output message mysql user was removed - name: assert output message mysql user was removed
assert: assert:
that: that:
- "result.changed == true" - result is changed
# ============================================================ # ============================================================
- name: create blank mysql user to be removed later - name: create blank mysql user to be removed later
@ -58,7 +58,7 @@
- name: assert changed is true for removing all blank users - name: assert changed is true for removing all blank users
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: remove blank mysql user with hosts=all (expect ok) - name: remove blank mysql user with hosts=all (expect ok)
mysql_user: mysql_user:
@ -71,4 +71,4 @@
- name: assert changed is true for removing all blank users - name: assert changed is true for removing all blank users
assert: assert:
that: that:
- "result.changed == false" - result is not changed

View file

@ -50,7 +50,7 @@
- name: Assert that there wasn't a change in permissions - name: Assert that there wasn't a change in permissions
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- name: Run command to show privileges for user (expect privileges in stdout) - name: Run command to show privileges for user (expect privileges in stdout)
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\"" command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\""
@ -76,7 +76,7 @@
- name: Assert that there was a change because permissions were added to data1.* - name: Assert that there was a change because permissions were added to data1.*
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Run command to show privileges for user (expect privileges in stdout) - name: Run command to show privileges for user (expect privileges in stdout)
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\"" command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\""

View file

@ -47,7 +47,7 @@
- name: Assert that there wasn't a change in permissions - name: Assert that there wasn't a change in permissions
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- name: Run command to show privileges for user (expect privileges in stdout) - name: Run command to show privileges for user (expect privileges in stdout)
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\"" command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\""
@ -72,7 +72,7 @@
- name: Assert that there was a change because permissions were/would be revoked on data1.* - name: Assert that there was a change because permissions were/would be revoked on data1.*
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Run command to show privileges for user (expect privileges in stdout) - name: Run command to show privileges for user (expect privileges in stdout)
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\"" command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\""
@ -104,7 +104,7 @@
- name: Assert that there was no change because invalid permissions are ignored - name: Assert that there was no change because invalid permissions are ignored
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- name: Run command to show privileges for user (expect privileges in stdout) - name: Run command to show privileges for user (expect privileges in stdout)
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\"" command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ user_name_4 }}'@'localhost'\""

View file

@ -51,7 +51,7 @@
- name: assert output message for current privileges - name: assert output message for current privileges
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: run command to show privileges for user (expect privileges in stdout) - name: run command to show privileges for user (expect privileges in stdout)
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{user_name_2}}'@'localhost'\"" command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{user_name_2}}'@'localhost'\""
@ -101,7 +101,7 @@
- name: Assert that priv changed - name: Assert that priv changed
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Add privs to a specific table (expect ok) - name: Add privs to a specific table (expect ok)
mysql_user: mysql_user:
@ -115,7 +115,7 @@
- name: Assert that priv did not change - name: Assert that priv did not change
assert: assert:
that: that:
- "result.changed == false" - result is not changed
# ============================================================ # ============================================================
- name: update user with all privileges - name: update user with all privileges
@ -162,7 +162,7 @@
- name: Assert that priv changed - name: Assert that priv changed
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Test idempotency (expect ok) - name: Test idempotency (expect ok)
mysql_user: mysql_user:
@ -177,7 +177,7 @@
- name: Assert that priv did not change - name: Assert that priv did not change
assert: assert:
that: that:
- "result.changed == false" - result is not changed
when: install_type == 'mysql' or (install_type == 'mariadb' and mariadb_version is version('10.2', '==')) when: install_type == 'mysql' or (install_type == 'mariadb' and mariadb_version is version('10.2', '=='))
# ============================================================ # ============================================================

View file

@ -32,7 +32,7 @@
- name: Assert that a change occurred because the user was added - name: Assert that a change occurred because the user was added
assert: assert:
that: that:
- "result.changed == true" - result is changed
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
@ -63,7 +63,7 @@
- name: Assert that there weren't any changes because username/password didn't change - name: Assert that there weren't any changes because username/password didn't change
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
@ -78,7 +78,7 @@
- name: Assert that a change occurred because the password was updated - name: Assert that a change occurred because the password was updated
assert: assert:
that: that:
- "result.changed == true" - result is changed
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
@ -131,7 +131,7 @@
- name: Assert that a change occurred because the user was added - name: Assert that a change occurred because the user was added
assert: assert:
that: that:
- "result.changed == true" - result is changed
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
@ -148,7 +148,7 @@
- name: Assert that there weren't any changes because username/password didn't change - name: Assert that there weren't any changes because username/password didn't change
assert: assert:
that: that:
- "result.changed == false" - result is not changed
# Cleanup # Cleanup
- include: remove_user.yml user_name={{ test_user_name }} user_password={{ new_password }} - include: remove_user.yml user_name={{ test_user_name }} user_password={{ new_password }}
@ -170,7 +170,7 @@
- name: Assert that a change occurred because the user was added - name: Assert that a change occurred because the user was added
assert: assert:
that: that:
- "result.changed == true" - result is changed
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
@ -200,7 +200,7 @@
- name: Assert that there weren't any changes because username/password didn't change - name: Assert that there weren't any changes because username/password didn't change
assert: assert:
that: that:
- "result.changed == false" - result is not changed
# Cleanup # Cleanup
- include: remove_user.yml user_name={{ test_user_name }} user_password={{ new_password }} - include: remove_user.yml user_name={{ test_user_name }} user_password={{ new_password }}
@ -220,7 +220,7 @@
- name: Assert that a change occurred because the user was added - name: Assert that a change occurred because the user was added
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Get the MySQL version using an empty password for the newly created user - name: Get the MySQL version using an empty password for the newly created user
mysql_info: mysql_info:
@ -263,7 +263,7 @@
- name: Assert that the user wasn't changed because the password is still empty - name: Assert that the user wasn't changed because the password is still empty
assert: assert:
that: that:
- "result.changed == false" - result is not changed
# Cleanup # Cleanup
- include: remove_user.yml user_name={{ test_user_name }} user_password='' - include: remove_user.yml user_name={{ test_user_name }} user_password=''

View file

@ -37,7 +37,7 @@
- name: Check that the module made a change - name: Check that the module made a change
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Check that the expected plugin type is set - name: Check that the expected plugin type is set
assert: assert:
@ -72,7 +72,7 @@
- name: Check that the module makes the change because the hash changed - name: Check that the module makes the change because the hash changed
assert: assert:
that: that:
- "result.changed == true" - result is changed
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
@ -113,7 +113,7 @@
- name: Check that the module made a change - name: Check that the module made a change
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Check that the expected plugin type is set - name: Check that the expected plugin type is set
assert: assert:
@ -149,7 +149,7 @@
- name: Check that the module doesn't make a change when the same hash is passed in - name: Check that the module doesn't make a change when the same hash is passed in
assert: assert:
that: that:
- "result.changed == false" - result is not changed
when: install_type == 'mysql' or (install_type == 'mariadb' and mariadb_version is version('10.3', '>=')) when: install_type == 'mysql' or (install_type == 'mariadb' and mariadb_version is version('10.3', '>='))
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
@ -166,7 +166,7 @@
- name: Check that the module did not change the password - name: Check that the module did not change the password
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Getting the MySQL info should still work - name: Getting the MySQL info should still work
mysql_info: mysql_info:
@ -205,7 +205,7 @@
- name: Check that the module made a change - name: Check that the module made a change
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Check that the expected plugin type is set - name: Check that the expected plugin type is set
assert: assert:
@ -242,7 +242,7 @@
- name: The module should detect a change even though the password is the same - name: The module should detect a change even though the password is the same
assert: assert:
that: that:
- "result.changed == true" - result is changed
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
@ -257,7 +257,7 @@
- name: Check that the module did not change the password - name: Check that the module did not change the password
assert: assert:
that: that:
- "result.changed == false" - result is not changed
- name: Get the MySQL version using the newly created creds - name: Get the MySQL version using the newly created creds
mysql_info: mysql_info:
@ -295,7 +295,7 @@
- name: Check that the module made a change - name: Check that the module made a change
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Check that the expected plugin type is set - name: Check that the expected plugin type is set
assert: assert:
@ -346,7 +346,7 @@
- name: Assert that the user wasn't changed because the auth string is still empty - name: Assert that the user wasn't changed because the auth string is still empty
assert: assert:
that: that:
- "result.changed == false" - result is not changed
# Cleanup # Cleanup
- include: remove_user.yml user_name={{ test_user_name }} user_password={{ test_plugin_auth_string }} - include: remove_user.yml user_name={{ test_user_name }} user_password={{ test_plugin_auth_string }}
@ -381,7 +381,7 @@
- name: Check that the module made a change - name: Check that the module made a change
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Check that the expected plugin type is set - name: Check that the expected plugin type is set
assert: assert:
@ -406,7 +406,7 @@
- name: Check that the module made a change - name: Check that the module made a change
assert: assert:
that: that:
- "result.changed == true" - result is changed
- name: Check that the expected plugin type is set - name: Check that the expected plugin type is set
assert: assert:

View file

@ -31,6 +31,6 @@
- name: assert output mysql variable name and value - name: assert output mysql variable name and value
assert: assert:
that: that:
- "result.changed | bool == true" - result is changed
- "'{{ var_name }}' in result.stdout" - "'{{ var_name }}' in result.stdout"
- "'{{ var_value }}' in result.stdout" - "'{{ var_value }}' in result.stdout"

View file

@ -35,6 +35,6 @@
- name: assert output variable info match mysql variable info - name: assert output variable info match mysql variable info
assert: assert:
that: that:
- "result.changed | bool == true" - result is changed
- "key_name in result.stdout" - "key_name in result.stdout"
- "key_value in result.stdout" - "key_value in result.stdout"