|
3 | 3 | # SPDX-License-Identifier: MIT
|
4 | 4 | from __future__ import annotations
|
5 | 5 |
|
| 6 | +import pytest |
| 7 | + |
6 | 8 | from deva._version import __version__
|
7 | 9 |
|
8 | 10 |
|
| 11 | +@pytest.fixture(scope="module") |
| 12 | +def next_major_version(): |
| 13 | + version_parts = list(map(int, __version__.split(".")[:3])) |
| 14 | + version_parts[0] += 1 |
| 15 | + return ".".join(map(str, version_parts)) |
| 16 | + |
| 17 | + |
9 | 18 | class TestVersionMismatch:
|
10 |
| - def test_root(self, deva, helpers, temp_dir): |
| 19 | + def test_root(self, deva, helpers, temp_dir, next_major_version): |
11 | 20 | version_file = temp_dir / ".deva-version"
|
12 | 21 | with temp_dir.as_cwd():
|
13 |
| - version_file.write_text("0.0.0") |
| 22 | + version_file.write_text(next_major_version) |
14 | 23 |
|
15 | 24 | result = deva("config")
|
16 | 25 |
|
17 | 26 | assert result.exit_code == 1, result.output
|
18 | 27 | assert result.output == helpers.dedent(
|
19 | 28 | f"""
|
20 |
| - deva version mismatch: {__version__} != 0.0.0 |
| 29 | + Repo requires at least deva version {next_major_version} but {__version__} is installed. |
| 30 | + Run the following command: |
| 31 | + deva self update |
21 | 32 | """
|
22 | 33 | )
|
23 | 34 |
|
24 |
| - def test_directory(self, deva, helpers, temp_dir): |
| 35 | + def test_directory(self, deva, helpers, temp_dir, next_major_version): |
25 | 36 | version_file = temp_dir / ".deva" / "version"
|
26 | 37 | version_file.parent.ensure_dir()
|
27 | 38 | with temp_dir.as_cwd():
|
28 |
| - version_file.write_text("0.0.0") |
| 39 | + version_file.write_text(next_major_version) |
29 | 40 |
|
30 | 41 | result = deva("config")
|
31 | 42 |
|
32 | 43 | assert result.exit_code == 1, result.output
|
33 | 44 | assert result.output == helpers.dedent(
|
34 | 45 | f"""
|
35 |
| - deva version mismatch: {__version__} != 0.0.0 |
| 46 | + Repo requires at least deva version {next_major_version} but {__version__} is installed. |
| 47 | + Run the following command: |
| 48 | + deva self update |
36 | 49 | """
|
37 | 50 | )
|
0 commit comments