|
| 1 | +""" test clone url parser """ |
| 2 | + |
| 3 | +from dist_git_client import parse_clone_url |
| 4 | + |
| 5 | + |
| 6 | +def _checker(url, hostname, path): |
| 7 | + parsed = parse_clone_url(url) |
| 8 | + assert parsed.hostname == hostname |
| 9 | + assert parsed.path == path |
| 10 | + |
| 11 | + |
| 12 | +def test_parse_clone_urls(): |
| 13 | + """ Basic clone url formats """ |
| 14 | + _checker("git@github.com:example/example-project.git", |
| 15 | + "github.com", "example/example-project.git") |
| 16 | + _checker("https://github.com/example/example-project.git", |
| 17 | + "github.com", "/example/example-project.git") |
| 18 | + _checker("https://github.com/example/example-project", |
| 19 | + "github.com", "/example/example-project") |
| 20 | + _checker("ssh://jdoe@pkgs.fedoraproject.org/rpms/example.git", |
| 21 | + "pkgs.fedoraproject.org", "/rpms/example.git") |
| 22 | + _checker("https://copr-dist-git.fedorainfracloud.org/git" |
| 23 | + "/@abrt/retrace-server-devel/retrace-server.git", |
| 24 | + "copr-dist-git.fedorainfracloud.org", |
| 25 | + "/git/@abrt/retrace-server-devel/retrace-server.git") |
| 26 | + _checker("file:///home/foo.git", |
| 27 | + "localhost", "/home/foo.git") |
| 28 | + _checker("/home/foo.git", |
| 29 | + "localhost", "/home/foo.git") |
0 commit comments