From abbec6b8e9cdf802efd163e50a256dc40a9a990f Mon Sep 17 00:00:00 2001 From: Veiko Aasa Date: Thu, 9 Sep 2021 22:16:40 +0300 Subject: [PATCH] gitweb: tests: Fix test failures if initial default branch is not master Since Git 2.28, it is possible to change initial default branch name using the configuration option init.defaultBranch. Closes #2101. Signed-off-by: Veiko Aasa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/gitweb/tests/test_actions.py | 29 +++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/plinth/modules/gitweb/tests/test_actions.py b/plinth/modules/gitweb/tests/test_actions.py index 2f1bc062c..26ccad990 100644 --- a/plinth/modules/gitweb/tests/test_actions.py +++ b/plinth/modules/gitweb/tests/test_actions.py @@ -17,7 +17,6 @@ REPO_DATA = { 'description': '', 'owner': '', 'access': 'private', - 'default_branch': 'master', } @@ -65,9 +64,11 @@ def test_create_repo(call_action): 'create-repo', '--name', REPO_NAME, '--description', '', '--owner', '', '--is-private', '--keep-ownership' ]) + repo = json.loads(call_action(['repo-info', '--name', REPO_NAME])) + default_branch = repo.pop('default_branch') - assert json.loads(call_action(['repo-info', '--name', - REPO_NAME])) == REPO_DATA + assert repo == REPO_DATA + assert len(default_branch) > 0 def test_change_repo_medatada(call_action, existing_repo): @@ -77,7 +78,6 @@ def test_change_repo_medatada(call_action, existing_repo): 'description': 'description2', 'owner': 'owner2', 'access': 'public', - 'default_branch': 'master', } call_action([ @@ -89,9 +89,10 @@ def test_change_repo_medatada(call_action, existing_repo): call_action([ 'set-repo-access', '--name', REPO_NAME, '--access', new_data['access'] ]) + repo = json.loads(call_action(['repo-info', '--name', REPO_NAME])) + del repo['default_branch'] - assert json.loads(call_action(['repo-info', '--name', - REPO_NAME])) == new_data + assert repo == new_data def test_rename_repository(call_action, existing_repo): @@ -101,21 +102,17 @@ def test_rename_repository(call_action, existing_repo): call_action(['rename-repo', '--oldname', REPO_NAME, '--newname', new_name]) with pytest.raises(RuntimeError, match='Repository not found'): call_action(['repo-info', '--name', REPO_NAME]) + repo = json.loads(call_action(['repo-info', '--name', new_name])) - assert json.loads(call_action(['repo-info', '--name', new_name])) == { - **REPO_DATA, - **{ - 'name': new_name - } - } + assert repo['name'] == new_name def test_get_branches(call_action, existing_repo): """Test getting all the branches of the repository.""" - assert json.loads(call_action(['get-branches', '--name', REPO_NAME])) == { - "default_branch": "master", - "branches": [] - } + result = json.loads(call_action(['get-branches', '--name', REPO_NAME])) + + assert 'default_branch' in result + assert result['branches'] == [] def test_delete_repository(call_action, existing_repo):