test_pin_github_action.py 622 B

12345678910111213141516171819
  1. import pytest
  2. from tools.pin_github_action import ACTION_VERSION_RE
  3. @pytest.mark.parametrize(
  4. ("s", "expected"),
  5. (
  6. ("uses: actions/cache@v1\n", ("actions/cache", "v1")),
  7. ("uses: actions/cache@v1 # after\n", ("actions/cache", "v1")),
  8. ("uses: actions/cache@v1# after\n", ("actions/cache", "v1")),
  9. ("uses: actions/cache@v1.0.0\n", ("actions/cache", "v1.0.0")),
  10. ("uses: actions/cache@v1.0.0 # after\n", ("actions/cache", "v1.0.0")),
  11. ),
  12. )
  13. def test_matches(s, expected):
  14. match = ACTION_VERSION_RE.search(s)
  15. assert match
  16. assert (match[1], match[2]) == expected