mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
docker_compose_v2: move some code to module_utils (#747)
* Move some code to module_utils. * Add unit tests. Test cases are auto-generated from integration test logs. * Rename ResourceEvent → Event.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
# Copyright 2022 Red Hat | Ansible
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible_collections.community.docker.plugins.module_utils.compose_v2 import (
|
||||
parse_events,
|
||||
)
|
||||
|
||||
from .compose_v2_test_cases import EVENT_TEST_CASES
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'test_id, compose_version, dry_run, stderr, events, warnings',
|
||||
EVENT_TEST_CASES,
|
||||
ids=[tc[0] for tc in EVENT_TEST_CASES],
|
||||
)
|
||||
def test_parse_events(test_id, compose_version, dry_run, stderr, events, warnings):
|
||||
collected_warnings = []
|
||||
|
||||
def collect_warning(msg):
|
||||
collected_warnings.append(msg)
|
||||
|
||||
collected_events = parse_events(stderr, dry_run=dry_run, warn_function=collect_warning)
|
||||
|
||||
assert events == collected_events
|
||||
assert warnings == collected_warnings
|
||||
Reference in New Issue
Block a user