Skip to content

Commit

Permalink
ci: Define test for 'age version'
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei committed Mar 18, 2024
1 parent e90d120 commit 4a32569
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Common test contexts."""

from pathlib import Path

import pytest


@pytest.fixture
def root() -> Path:
"""Path-object of project root."""
return Path(__file__).parent.parent


@pytest.fixture
def target_bin(root: Path) -> str:
"""Full-path of binary generated by ``cargo build``."""
bin_path = root / "target" / "debug" / "age"
return str(bin_path.resolve())
12 changes: 12 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Test case for ``age version``."""

import tomllib
from pathlib import Path
from subprocess import PIPE, run


def test_it(root: Path, target_bin: str): # noqa: D103
cargo = tomllib.loads((root / "Cargo.toml").read_text())
proc = run([target_bin, "version"], stdout=PIPE, stderr=PIPE, text=True)
assert proc.returncode == 0
assert f"v{cargo['package']['version']}" in proc.stdout

0 comments on commit 4a32569

Please sign in to comment.