|
6 | 6 | _convert_markdown_to_rst, |
7 | 7 | _plugin_min_snakemake, |
8 | 8 | _commit_url, |
| 9 | + _cleanup_repository_url, |
9 | 10 | ) |
10 | 11 |
|
11 | 12 |
|
@@ -253,3 +254,66 @@ def test_commit_url_unknown_type_non_none(): |
253 | 254 | """Test unknown repository type string returns base URL.""" |
254 | 255 | url = _commit_url("https://bitbucket.org/user/repo", "bitbucket", "abc1234") |
255 | 256 | assert url == "https://bitbucket.org/user/repo" |
| 257 | + |
| 258 | + |
| 259 | +# Repository URL cleanup tests |
| 260 | + |
| 261 | + |
| 262 | +def test_cleanup_repository_url_github_https(): |
| 263 | + """Test cleaning up GitHub HTTPS URL.""" |
| 264 | + cleaned = _cleanup_repository_url("https://github.com/user/repo") |
| 265 | + assert cleaned == "user/repo" |
| 266 | + |
| 267 | + |
| 268 | +def test_cleanup_repository_url_github_with_git_suffix(): |
| 269 | + """Test cleaning up GitHub URL with .git suffix.""" |
| 270 | + cleaned = _cleanup_repository_url("https://github.com/user/repo.git") |
| 271 | + assert cleaned == "user/repo" |
| 272 | + |
| 273 | + |
| 274 | +def test_cleanup_repository_url_github_with_trailing_slash(): |
| 275 | + """Test cleaning up GitHub URL with trailing slash.""" |
| 276 | + cleaned = _cleanup_repository_url("https://github.com/user/repo/") |
| 277 | + assert cleaned == "user/repo" |
| 278 | + |
| 279 | + |
| 280 | +def test_cleanup_repository_url_github_full(): |
| 281 | + """Test cleaning up GitHub URL with .git and trailing slash.""" |
| 282 | + cleaned = _cleanup_repository_url("https://github.com/user/repo.git/") |
| 283 | + assert cleaned == "user/repo" |
| 284 | + |
| 285 | + |
| 286 | +def test_cleanup_repository_url_gitlab_https(): |
| 287 | + """Test cleaning up GitLab HTTPS URL.""" |
| 288 | + cleaned = _cleanup_repository_url("https://gitlab.com/user/repo") |
| 289 | + assert cleaned == "user/repo" |
| 290 | + |
| 291 | + |
| 292 | +def test_cleanup_repository_url_gitlab_with_git_suffix(): |
| 293 | + """Test cleaning up GitLab URL with .git suffix.""" |
| 294 | + cleaned = _cleanup_repository_url("https://gitlab.com/user/repo.git") |
| 295 | + assert cleaned == "user/repo" |
| 296 | + |
| 297 | + |
| 298 | +def test_cleanup_repository_url_http_protocol(): |
| 299 | + """Test cleaning up URL with HTTP protocol.""" |
| 300 | + cleaned = _cleanup_repository_url("http://github.com/user/repo") |
| 301 | + assert cleaned == "user/repo" |
| 302 | + |
| 303 | + |
| 304 | +def test_cleanup_repository_url_empty_string(): |
| 305 | + """Test cleaning up empty string.""" |
| 306 | + cleaned = _cleanup_repository_url("") |
| 307 | + assert cleaned == "" |
| 308 | + |
| 309 | + |
| 310 | +def test_cleanup_repository_url_none(): |
| 311 | + """Test cleaning up None value.""" |
| 312 | + cleaned = _cleanup_repository_url(None) |
| 313 | + assert cleaned == "" |
| 314 | + |
| 315 | + |
| 316 | +def test_cleanup_repository_url_other_domain(): |
| 317 | + """Test cleaning up URL from other domain remains unchanged.""" |
| 318 | + cleaned = _cleanup_repository_url("https://bitbucket.org/user/repo") |
| 319 | + assert cleaned == "https://bitbucket.org/user/repo" |
0 commit comments