| 1 |
|
| 2 |
|
| 3 |
import unittest |
| 4 |
|
| 5 |
from parameterized import parameterized |
| 6 |
|
| 7 |
from podman_compose import is_context_git_url |
| 8 |
|
| 9 |
|
| 10 |
class TestIsContextGitUrl(unittest.TestCase): |
| 11 |
@parameterized.expand([ |
| 12 |
("with_url_fragment", "http://host.xz/path/to/repo.git#fragment", True), |
| 13 |
("suffix_and_prefix", "git://host.xz/path/to/repo.git", True), |
| 14 |
("empty_url_path", "http://#fragment", True), |
| 15 |
("no_prefix", "http://host.xz/path/to/repo", True), |
| 16 |
("wrong_prefix_git", "gitt://host.xz/path/to/repo", False), |
| 17 |
("wrong_prefix_http", "htt://host.xz/path/to/repo.git", False), |
| 18 |
("user_path_ending_with_git", "path/to/workdir.git", False), |
| 19 |
("", "/path/to/workdir.git", False), |
| 20 |
("", "/path/to:workdir.git", False), |
| 21 |
("", "/path/[email protected]", False), |
| 22 |
("", "~/path/to/workdir.git", False), |
| 23 |
|
| 24 |
("", "http://example.com/my-project.git", True), |
| 25 |
("", "file:///absolute/path/to/my-project.git", True), |
| 26 |
("", "ssh:[email protected]:my-project", True), |
| 27 |
("", "[email protected]:user/project.git", True), |
| 28 |
("", "https://github.com/user/project.git", True), |
| 29 |
("", "http://github.com/user/project.git", True), |
| 30 |
("", "[email protected]:user/project.git", True), |
| 31 |
("", "https://192.168.101.127/user/project.git", True), |
| 32 |
("", "http://192.168.101.127/user/project.git", True), |
| 33 |
("", "ssh://[email protected]:port/path/to/repo.git/", True), |
| 34 |
("", "ssh://[email protected]/path/to/repo.git/", True), |
| 35 |
("", "ssh://host.xz:port/path/to/repo.git/", True), |
| 36 |
("", "ssh://host.xz/path/to/repo.git/", True), |
| 37 |
("", "ssh://[email protected]/path/to/repo.git/", True), |
| 38 |
("", "ssh://host.xz/path/to/repo.git/", True), |
| 39 |
("", "ssh://[email protected]/~user/path/to/repo.git/", True), |
| 40 |
("", "ssh://host.xz/~user/path/to/repo.git/", True), |
| 41 |
("", "ssh://[email protected]/~/path/to/repo.git", True), |
| 42 |
("", "ssh://host.xz/~/path/to/repo.git", True), |
| 43 |
("", "git://host.xz/path/to/repo.git/", True), |
| 44 |
("", "git://host.xz/~user/path/to/repo.git/", True), |
| 45 |
("", "http://host.xz/path/to/repo.git/", True), |
| 46 |
("", "https://host.xz/path/to/repo.git/", True), |
| 47 |
("", "git@custom-gitlab:my-group/myrepo.git", True), |
| 48 |
("", "ssh://[email protected]:port/path/to/repo.git/", True), |
| 49 |
("", "ssh://[email protected]/path/to/repo.git/", True), |
| 50 |
("", "ssh://host.xz:port/path/to/repo.git/", True), |
| 51 |
("", "ssh://host.xz/path/to/repo.git/", True), |
| 52 |
("", "ssh://[email protected]/path/to/repo.git/", True), |
| 53 |
("", "ssh://host.xz/path/to/repo.git/", True), |
| 54 |
("", "ssh://[email protected]/~user/path/to/repo.git/", True), |
| 55 |
("", "ssh://host.xz/~user/path/to/repo.git/", True), |
| 56 |
("", "ssh://[email protected]/~/path/to/repo.git", True), |
| 57 |
("", "ssh://host.xz/~/path/to/repo.git", True), |
| 58 |
("", "git://host.xz/path/to/repo.git/", True), |
| 59 |
("", "git://host.xz/~user/path/to/repo.git/", True), |
| 60 |
("", "http://host.xz/path/to/repo.git/", True), |
| 61 |
("", "https://host.xz/path/to/repo.git/", True), |
| 62 |
("", "ssh:[email protected]:my-project", True), |
| 63 |
("", "[email protected]:/path/to/repo.git/", True), |
| 64 |
("", "host.xz:/path/to/repo.git/", True), |
| 65 |
("", "host:path/to/repo.git", True), |
| 66 |
("", "host:path/to/repo", True), |
| 67 |
("", "[email protected]:~user/path/to/repo.git/", True), |
| 68 |
("", "host.xz:~user/path/to/repo.git/", True), |
| 69 |
("", "[email protected]:path/to/repo.git", True), |
| 70 |
("", "user@path/to/repo", True), |
| 71 |
("", "host.xz:path/to/repo.git", True), |
| 72 |
("", "rsync://host.xz/path/to/repo.git/", True), |
| 73 |
("", "file:///path/to/repo.git/", True), |
| 74 |
("", "file://~/path/to/repo.git/", True), |
| 75 |
("", "github.com:containers/podman-compose.git", True), |
| 76 |
("", "github:containers/podman-compose.git", True), |
| 77 |
("", "https://github.com/test_repo.git/git_not_suffix", True), |
| 78 |
]) |
| 79 |
def test_is_path_git_url(self, test_name: str, path: str, result: bool) -> None: |
| 80 |
self.assertEqual(is_context_git_url(path), result) |