mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-19 17:01:26 -07:00
mysql_replication: fix crashes caused by deprecated terminology (#71)
* mysql_replication: fix crashes caused by deprecated terminology * Fix unrelated sanity errors * Tests: mysql 8.0.21 -> 8.022 * Adjust integration tests * Add version check to the tests * Add debug statement * Adjust mysql version * Fix tests * Add unit tests * Add changelog fragment * Improve code and coverage * Get rid of extra blank line * Improve coverage * Change suggested
This commit is contained in:
parent
b7e828a092
commit
ebe503823a
8 changed files with 194 additions and 29 deletions
47
tests/unit/plugins/modules/test_mysql_replication.py
Normal file
47
tests/unit/plugins/modules/test_mysql_replication.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright: (c) 2020, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible_collections.community.mysql.plugins.modules.mysql_replication import uses_replica_terminology
|
||||
|
||||
|
||||
class dummy_cursor_class():
|
||||
def __init__(self, output, ret_val_type='dict'):
|
||||
self.output = output
|
||||
self.ret_val_type = ret_val_type
|
||||
|
||||
def execute(self, query):
|
||||
pass
|
||||
|
||||
def fetchone(self):
|
||||
if self.ret_val_type == 'dict':
|
||||
return {'version': self.output}
|
||||
|
||||
elif self.ret_val_type == 'list':
|
||||
return [self.output]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'f_output,c_output,c_ret_type',
|
||||
[
|
||||
(False, '5.5.1-mysql', 'list'),
|
||||
(False, '5.7.0-mysql', 'dict'),
|
||||
(False, '8.0.0-mysql', 'list'),
|
||||
(False, '8.0.11-mysql', 'dict'),
|
||||
(False, '8.0.21-mysql', 'list'),
|
||||
(False, '10.5.0-mariadb', 'dict'),
|
||||
(True, '8.0.22-mysql', 'list'),
|
||||
(True, '8.1.2-mysql', 'dict'),
|
||||
(True, '9.0.0-mysql', 'list'),
|
||||
(True, '10.5.1-mariadb', 'dict'),
|
||||
(True, '10.6.0-mariadb', 'dict'),
|
||||
(True, '11.5.1-mariadb', 'dict'),
|
||||
]
|
||||
)
|
||||
def test_uses_replica_terminology(f_output, c_output, c_ret_type):
|
||||
cursor = dummy_cursor_class(c_output, c_ret_type)
|
||||
assert uses_replica_terminology(cursor) == f_output
|
Loading…
Add table
Add a link
Reference in a new issue