fix unit tests

This commit is contained in:
Laurent Indermuehle 2024-04-11 20:07:04 +02:00
parent e22e8939e2
commit ca810667cc
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09

View file

@ -14,15 +14,15 @@ from ansible_collections.community.mysql.plugins.modules.mysql_info import MySQL
@pytest.mark.parametrize( @pytest.mark.parametrize(
'suffix,cursor_output,server_implementation', 'suffix,cursor_output,server_implementation,user_implementation',
[ [
('mysql', '5.5.1-mysql', 'mysql'), ('mysql', '5.5.1-mysql', 'mysql','mysql'),
('log', '5.7.31-log', 'mysql'), ('log', '5.7.31-log', 'mysql','mysql'),
('mariadb', '10.5.0-mariadb', 'mariadb'), ('mariadb', '10.5.0-mariadb', 'mariadb','mariadb'),
('', '8.0.22', 'mysql'), ('', '8.0.22', 'mysql','mysql'),
] ]
) )
def test_get_info_suffix(suffix, cursor_output, server_implementation): def test_get_info_suffix(suffix, cursor_output, server_implementation, user_implementation):
def __cursor_return_value(input_parameter): def __cursor_return_value(input_parameter):
if input_parameter == "SHOW GLOBAL VARIABLES": if input_parameter == "SHOW GLOBAL VARIABLES":
cursor.fetchall.return_value = [{"Variable_name": "version", "Value": cursor_output}] cursor.fetchall.return_value = [{"Variable_name": "version", "Value": cursor_output}]
@ -32,6 +32,6 @@ def test_get_info_suffix(suffix, cursor_output, server_implementation):
cursor = MagicMock() cursor = MagicMock()
cursor.execute.side_effect = __cursor_return_value cursor.execute.side_effect = __cursor_return_value
info = MySQL_Info(MagicMock(), cursor, server_implementation) info = MySQL_Info(MagicMock(), cursor, server_implementation, user_implementation)
assert info.get_info([], [], False)['version']['suffix'] == suffix assert info.get_info([], [], False)['version']['suffix'] == suffix