-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add version comparison logic (#8902)
- Loading branch information
Showing
2 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
|
||
from controllers.console.version import _has_new_version | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("latest_version", "current_version", "expected"), | ||
[ | ||
("1.0.1", "1.0.0", True), | ||
("1.1.0", "1.0.0", True), | ||
("2.0.0", "1.9.9", True), | ||
("1.0.0", "1.0.0", False), | ||
("1.0.0", "1.0.1", False), | ||
("1.0.0", "2.0.0", False), | ||
("1.0.1", "1.0.0-beta", True), | ||
("1.0.0", "1.0.0-alpha", True), | ||
("1.0.0-beta", "1.0.0-alpha", True), | ||
("1.0.0", "1.0.0-rc1", True), | ||
("1.0.0", "0.9.9", True), | ||
("1.0.0", "1.0.0-dev", True), | ||
], | ||
) | ||
def test_has_new_version(latest_version, current_version, expected): | ||
assert _has_new_version(latest_version=latest_version, current_version=current_version) == expected | ||
|
||
|
||
def test_has_new_version_invalid_input(): | ||
with pytest.raises(ValueError): | ||
_has_new_version(latest_version="1.0", current_version="1.0.0") | ||
|
||
with pytest.raises(ValueError): | ||
_has_new_version(latest_version="1.0.0", current_version="1.0") | ||
|
||
with pytest.raises(ValueError): | ||
_has_new_version(latest_version="invalid", current_version="1.0.0") | ||
|
||
with pytest.raises(ValueError): | ||
_has_new_version(latest_version="1.0.0", current_version="invalid") |