Skip to content

Commit

Permalink
Support testing dests with backrefs
Browse files Browse the repository at this point in the history
  • Loading branch information
natefoo committed Feb 1, 2023
1 parent 81321f1 commit 8acca0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 4 additions & 2 deletions group_vars/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,7 @@ gxy_io_rewrites:
- src: "/t/(.*)"
dest: "https://training.galaxyproject.org/training-material/short/\\1"
tests:
- /t/ansible-galaxy
- /t/galaxy-intro-101
- src: /t/ansible-galaxy
dest: https://training.galaxyproject.org/training-material/short/ansible-galaxy
- src: /t/galaxy-intro-101
dest: https://training.galaxyproject.org/training-material/short/galaxy-intro-101
14 changes: 6 additions & 8 deletions tests/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@ def event_for_uri(uri):


def test_rewrite(rewrite, test_collector):
for test_uri in rewrite.get("tests", [rewrite["src"]]):
event = event_for_uri(test_uri)
for test_def in rewrite.get("tests", [rewrite["src"]]):
if not isinstance(test_def, dict):
test_def = {"src": test_def, "dest": rewrite["dest"]}
event = event_for_uri(test_def["src"])
location = lambda_handler(event, None)["headers"]["location"][0]["value"]
test_name = f"{test_uri}: {location} -> {rewrite['dest']}"
if '\\1' in rewrite['dest']:
# Skip tests with replacements?
test_collector.add_results(True, test_name)
else:
test_collector.add_results(location == rewrite["dest"], test_name)
test_name = f"{test_def['src']}: {location} -> {test_def['dest']}"
test_collector.add_results(location == test_def["dest"], test_name)


def main():
Expand Down

0 comments on commit 8acca0d

Please sign in to comment.