Files
sentinel/tests/tools/test_pin_github_action.py
2024-02-15 17:01:50 +00:00

20 lines
622 B
Python

import pytest
from tools.pin_github_action import ACTION_VERSION_RE
@pytest.mark.parametrize(
("s", "expected"),
(
("uses: actions/cache@v1\n", ("actions/cache", "v1")),
("uses: actions/cache@v1 # after\n", ("actions/cache", "v1")),
("uses: actions/cache@v1# after\n", ("actions/cache", "v1")),
("uses: actions/[email protected]\n", ("actions/cache", "v1.0.0")),
("uses: actions/[email protected] # after\n", ("actions/cache", "v1.0.0")),
),
)
def test_matches(s, expected):
match = ACTION_VERSION_RE.search(s)
assert match
assert (match[1], match[2]) == expected