generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add mysql_full_version and suffix return variable (#115)
* add mysql_full_version and suffix return variable add changelog fragment * rephrase changelog fragment * Update plugins/modules/mysql_info.py Co-authored-by: Andrew Klychkov <[email protected]> * Add changes as per PR review * Add tests for new suffix output parameter Co-authored-by: Andrew Klychkov <[email protected]> Co-authored-by: Jorge-Rodriguez <[email protected]>
- Loading branch information
1 parent
2254b29
commit a5ee4b3
Showing
4 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/115-add_mysql_full_version_suffix_return_var.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- mysql_info - add `version.full` and `version.suffix` return values (https:/ansible-collections/community.mysql/issues/114). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |