|
4 | 4 |
|
5 | 5 | from parameterized import parameterized |
6 | 6 |
|
7 | | -from podman_compose import is_path_git_url |
| 7 | +from podman_compose import is_context_git_url |
8 | 8 |
|
9 | 9 |
|
10 | 10 | class TestIsPathGitUrl(unittest.TestCase): |
11 | 11 | @parameterized.expand([ |
12 | | - ("prefix_git", "git://host.xz/path/to/repo", True), |
13 | | - ("prefix_almost_git", "gitt://host.xz/path/to/repo", False), |
14 | | - ("prefix_wrong", "http://host.xz/path/to/repo", False), |
15 | | - ("suffix_git", "http://host.xz/path/to/repo.git", True), |
16 | | - ("suffix_wrong", "http://host.xz/path/to/repo", False), |
17 | | - ("suffix_with_url_fragment", "http://host.xz/path/to/repo.git#fragment", True), |
| 12 | + ("with_url_fragment", "http://host.xz/path/to/repo.git#fragment", True), |
18 | 13 | ("suffix_and_prefix", "git://host.xz/path/to/repo.git", True), |
19 | | - ("empty_url_path", "http://#fragment", False), |
| 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/to@workdir.git", False), |
| 22 | + ("", "~/path/to/workdir.git", False), |
| 23 | + # many of possible ways git url can look like |
| 24 | + ("", "http://example.com/my-project.git", True), |
| 25 | + ("", "file:///absolute/path/to/my-project.git", True), |
| 26 | + ("", "ssh:user@example.com:my-project", True), |
| 27 | + ("", "git@github.com:user/project.git", True), |
| 28 | + ("", "https://github.com/user/project.git", True), |
| 29 | + ("", "http://github.com/user/project.git", True), |
| 30 | + ("", "git@192.168.101.127: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://user@host.xz:port/path/to/repo.git/", True), |
| 34 | + ("", "ssh://user@host.xz/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://user@host.xz/path/to/repo.git/", True), |
| 38 | + ("", "ssh://host.xz/path/to/repo.git/", True), |
| 39 | + ("", "ssh://user@host.xz/~user/path/to/repo.git/", True), |
| 40 | + ("", "ssh://host.xz/~user/path/to/repo.git/", True), |
| 41 | + ("", "ssh://user@host.xz/~/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://user@host.xz:port/path/to/repo.git/", True), |
| 49 | + ("", "ssh://user@host.xz/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://user@host.xz/path/to/repo.git/", True), |
| 53 | + ("", "ssh://host.xz/path/to/repo.git/", True), |
| 54 | + ("", "ssh://user@host.xz/~user/path/to/repo.git/", True), |
| 55 | + ("", "ssh://host.xz/~user/path/to/repo.git/", True), |
| 56 | + ("", "ssh://user@host.xz/~/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:user@example.com:my-project", True), |
| 63 | + ("", "user@host.xz:/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 | + ("", "user@host.xz:~user/path/to/repo.git/", True), |
| 68 | + ("", "host.xz:~user/path/to/repo.git/", True), |
| 69 | + ("", "user@host.xz: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), |
20 | 77 | ]) |
21 | 78 | def test_is_path_git_url(self, test_name: str, path: str, result: bool) -> None: |
22 | | - self.assertEqual(is_path_git_url(path), result) |
| 79 | + self.assertEqual(is_context_git_url(path), result) |
0 commit comments