|
| 1 | +import pytest |
| 2 | + |
| 3 | +from dstack._internal.cli.utils import updates |
| 4 | + |
| 5 | + |
| 6 | +@pytest.mark.parametrize( |
| 7 | + "current_version,latest_version,expected", |
| 8 | + [ |
| 9 | + ("1.0.0", "1.0.1", True), # patch update, both releases |
| 10 | + ("1.0.0", "2.0.0", True), # major update, both releases |
| 11 | + ("1.0.0", "1.0.0", False), # same version |
| 12 | + ("1.1.0", "1.0.9", False), # downgrade |
| 13 | + ("1.0.0a1", "1.0.0", True), # pre-release to release (should show update) |
| 14 | + ("1.0.0", "1.0.0a1", False), # release to pre-release (should NOT show update) |
| 15 | + ("1.0.0b1", "1.0.0b2", True), # beta to beta (should show update) |
| 16 | + ("1.0.0rc1", "1.0.0", True), # rc to release (should show update) |
| 17 | + ("1.0.0", "1.0.0rc1", False), # release to rc (should NOT show update) |
| 18 | + ("1.0.0a1", "1.0.0b1", True), # alpha to beta (should show update) |
| 19 | + ("1.0.0b1", "1.0.0rc1", True), # beta to rc (should show update) |
| 20 | + ("1.0.0rc1", "1.0.1a1", True), # rc to next alpha (should show update) |
| 21 | + ], |
| 22 | +) |
| 23 | +def test_is_update_available(current_version, latest_version, expected): |
| 24 | + assert updates.is_update_available(current_version, latest_version) == expected |
0 commit comments