mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-08 19:50:31 -07:00
Add tests for new suffix output parameter
This commit is contained in:
parent
20ce789f1b
commit
63595b9c3e
1 changed files with 37 additions and 0 deletions
37
tests/unit/plugins/modules/test_mysql_info.py
Normal file
37
tests/unit/plugins/modules/test_mysql_info.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
try:
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
except ImportError:
|
||||||
|
from mock import MagicMock
|
||||||
|
|
||||||
|
from ansible_collections.community.mysql.plugins.modules.mysql_info import MySQL_Info
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'suffix,cursor_output',
|
||||||
|
[
|
||||||
|
('mysql', '5.5.1-mysql'),
|
||||||
|
('log', '5.7.31-log'),
|
||||||
|
('mariadb', '10.5.0-mariadb'),
|
||||||
|
('', '8.0.22'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_get_info_suffix(suffix, cursor_output):
|
||||||
|
def __cursor_return_value(input_parameter):
|
||||||
|
if input_parameter == "SHOW GLOBAL VARIABLES":
|
||||||
|
cursor.fetchall.return_value = [{"Variable_name": "version", "Value": cursor_output}]
|
||||||
|
else:
|
||||||
|
cursor.fetchall.return_value = MagicMock()
|
||||||
|
|
||||||
|
cursor = MagicMock()
|
||||||
|
cursor.execute.side_effect = __cursor_return_value
|
||||||
|
|
||||||
|
info = MySQL_Info(MagicMock(), cursor)
|
||||||
|
|
||||||
|
assert info.get_info([], [], False)['version']['suffix'] == suffix
|
Loading…
Add table
Reference in a new issue