-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test: vcs.git.backend tests #9507
base: main
Are you sure you want to change the base?
Test: vcs.git.backend tests #9507
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See suggestions.
PS: Please do not use "Resolves" for a permanent issue (because it will be closed automatically if your PR is merged). I changed it to "Relates-to".
tests/vcs/git/test_backend.py
Outdated
def test_git_ref_spec_resolve_branch(fetch_pack_result: FetchPackResult) -> None: | ||
mock_fetch_pack_result = fetch_pack_result | ||
|
||
refspec = GitRefSpec(branch="main") | ||
refspec.resolve(mock_fetch_pack_result) | ||
|
||
assert refspec.ref == b"refs/heads/main" | ||
assert refspec.branch == "main" | ||
assert refspec.revision is None | ||
assert refspec.tag is None | ||
|
||
|
||
def test_git_ref_spec_resolve_tag(fetch_pack_result: FetchPackResult) -> None: | ||
mock_fetch_pack_result = fetch_pack_result | ||
|
||
refspec = GitRefSpec(revision="v1.0.0") | ||
refspec.resolve(mock_fetch_pack_result) | ||
|
||
assert refspec.ref == annotated_tag(b"refs/tags/v1.0.0") | ||
assert refspec.branch is None | ||
assert refspec.revision is None | ||
assert refspec.tag == "v1.0.0" | ||
|
||
|
||
def test_git_ref_spec_resolve_sha(fetch_pack_result: FetchPackResult) -> None: | ||
mock_fetch_pack_result = fetch_pack_result | ||
|
||
refspec = GitRefSpec(revision="abc") | ||
|
||
refspec.resolve(mock_fetch_pack_result) | ||
|
||
assert refspec.ref == b"refs/heads/main" | ||
assert refspec.branch is None | ||
assert refspec.tag is None | ||
assert refspec.revision == "abc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we merge these three ref_spec_resolve
tests into one parameterized test?
There are still some uncovered branches in _normalise
, e.g. specifying a branch
as revision
, which can be covered easily. If we add more test variants, a parameterized tests will make even more sense.
Pull Request Check List
Relates-to: #3155
poetry.vcs.git.backend
(increased coverage from 30% to 51%)