|
5 | 5 | from unittest.mock import patch |
6 | 6 | from pytest_httpserver import HTTPServer |
7 | 7 | from pytest import LogCaptureFixture, raises |
8 | | -from tests.test_utils import get_url_root, expect_request, mock_cloned_repo |
| 8 | +from tests.test_utils import get_url_root, expect_request, mock_cloned_repo, load_json |
9 | 9 |
|
10 | 10 |
|
11 | 11 | def get_test_args_github_to_gitea(httpserver: HTTPServer): |
@@ -327,3 +327,26 @@ def test_from_github_to_gitea_all_already_sync(httpserver: HTTPServer, caplog: L |
327 | 327 | assert 'Synchronize branch...' not in caplog.text |
328 | 328 | assert 'All branches already synchronized, do tags only...' not in caplog.text |
329 | 329 | assert 'Git Platforms Synchronization finished sucessfully. Repos updated: 0/1. Branches updated: 0/2' in caplog.text |
| 330 | + |
| 331 | + |
| 332 | +def test_from_github_to_gitea_tags_diff_sync(httpserver: HTTPServer, caplog: LogCaptureFixture): |
| 333 | + # GitHub with spring-projects |
| 334 | + prepare_github_with_spring_projects(httpserver, prepare_tags=False) |
| 335 | + httpserver.expect_request('/repos/spring-projects/spring-petclinic/tags').respond_with_json( |
| 336 | + load_json('tests/http_mocks/github/repos/spring-projects/spring-petclinic/tags-changed.json')) |
| 337 | + |
| 338 | + # Gitea with same repo |
| 339 | + prepare_gitea_with_spring_projects(httpserver, prepare_tags=False) |
| 340 | + httpserver.expect_request( |
| 341 | + '/api/v1/repos/MyOrg/spring-petclinic/tags', |
| 342 | + query_string='page=1').respond_with_json(load_json('tests/http_mocks/gitea/api/v1/repos/MyOrg/spring-petclinic/tags-changed.json')) |
| 343 | + httpserver.expect_request('/api/v1/repos/MyOrg/spring-petclinic/tags', query_string='page=2').respond_with_json([]) |
| 344 | + |
| 345 | + # Clone will be engaged for tags sync |
| 346 | + with raises(GitCommandError): |
| 347 | + with patch.object(sys, 'argv', get_test_args_github_to_gitea(httpserver)): |
| 348 | + git_platforms_synchro.main() |
| 349 | + |
| 350 | + assert 'Already synchronized.' in caplog.text |
| 351 | + assert 'Synchronize branch...' not in caplog.text |
| 352 | + assert 'All branches already synchronized, do tags only...' in caplog.text |
0 commit comments