mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-03 20:54:25 -07:00
fix 'fail' tests
This commit is contained in:
parent
781bf601e7
commit
54b4effcc6
3 changed files with 107 additions and 58 deletions
|
@ -17,3 +17,24 @@ class dummy_cursor_class():
|
|||
|
||||
elif self.ret_val_type == 'list':
|
||||
return [self.output]
|
||||
|
||||
|
||||
class MockCursor:
|
||||
def __init__(self, status="ONLINE"):
|
||||
self.status = status
|
||||
self.executed_queries = []
|
||||
|
||||
def execute(self, query):
|
||||
self.executed_queries.append(query)
|
||||
if self.status == "ERROR":
|
||||
# Create a custom exception that mimics mysql_driver.Warning
|
||||
class MockWarning(Exception):
|
||||
pass
|
||||
# Make it available as a class attribute for tests to use
|
||||
MockCursor.Warning = MockWarning
|
||||
raise MockWarning("Mocked execution error")
|
||||
|
||||
def fetchone(self):
|
||||
if len(self.executed_queries) > 0 and "group_replication_status" in self.executed_queries[-1]:
|
||||
return ["group_replication_status", self.status]
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue