Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
No-Issue

Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner committed Aug 8, 2023
1 parent 3779fd0 commit 406cc54
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
53 changes: 53 additions & 0 deletions galaxy_ng/tests/integration/api/test_artifact_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
wait_for_task,
)

from ..utils import build_collection as bc


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -425,6 +428,56 @@ def test_ansible_lint_exception(ansible_config, upload_artifact, hub_version):
assert len(stderr_msg) == 0 # this stderr message not in log


@pytest.mark.stage_health
@pytest.mark.importer
@pytest.mark.all
def test_ansible_lint_exception_AAH_2606(ansible_config, upload_artifact, hub_version):
"""
https://issues.redhat.com/browse/AAH-2609
- ansible-lint output is missing.
"""
config = ansible_config("basic_user")
api_client = get_client(config)

IGNORE_CONTENT = \
"plugins/modules/lm_otel_collector.py validate-modules:use-run-command-not-popen\n"

expected = [
(
"meta/runtime.yml:1: meta-runtime[unsupported-version]:"
+ " requires_ansible key must be set to a supported version."
),
(
"meta/runtime.yml:1: yaml[new-line-at-end-of-file]:"
+ " No new line character at the end of file"
),
(
"tests/sanity/ignore-2.10.txt:1: sanity[cannot-ignore]:"
+ " Ignore file contains validate-modules:use-run-command-not-popen at line 1,"
+ " which is not a permitted ignore."
)
]

artifact = bc(
"skeleton",
config={
"namespace": USERNAME_PUBLISHER,
"tags": ["database"],
},
extra_files={
"meta/runtime.yml": "requires_ansible: \">=2.10\"",
"tests/sanity/ignore-2.10.txt": IGNORE_CONTENT,
},
)

resp = upload_artifact(config, api_client, artifact)
resp = wait_for_task(api_client, resp)
log_messages = [item["message"] for item in resp["messages"]]
log_messages = "\n".join(log_messages)
for line in expected:
assert line in log_messages, log_messages


@pytest.mark.importer
@pytest.mark.all
def test_api_publish_log_missing_ee_deps(ansible_config, upload_artifact):
Expand Down
13 changes: 12 additions & 1 deletion galaxy_ng/tests/integration/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,18 @@ def build_collection(
f.write('')

if extra_files:
raise Exception('extra_files not yet implemented')
for ename, econtent in extra_files.items():
fpath = os.path.join(basedir, ename)
fdir = os.path.dirname(fpath)
if not os.path.exists(fdir):
os.makedirs(fdir)
with open(fpath, 'w') as f:
if isinstance(econtent, dict) and econtent.get('mimetype') == 'yaml':
yaml.dump(econtent['content'], f)
elif isinstance(econtent, dict):
f.write(econtent['content'])
else:
f.write(econtent)

if pre_build:
raise Exception('pre_build not yet implemented')
Expand Down

0 comments on commit 406cc54

Please sign in to comment.