Skip to content

Commit

Permalink
ci: Add test for preset args in 'init'
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei committed Mar 21, 2024
1 parent 25a356b commit cddd05a
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
"""Test case for ``age init``."""

from pathlib import Path
from subprocess import PIPE, run

import pytest

def test_it(target_bin: str, tmp_path: Path):

def test_it(cmd, tmp_path: Path):
"""'init' command generate config file."""
proc = cmd("init")
assert proc.returncode == 0
#
age_toml = tmp_path / ".age.toml"
assert age_toml.exists()
age_text = age_toml.read_text()
assert 'current_version = "0.0.0"' in age_text


@pytest.mark.parametrize(
"presets,files",
[
(["rust"], ["Cargo.toml"]),
(["python"], ["pyproject.toml"]),
(["rust", "python"], ["Cargo.toml", "pyproject.toml"]),
],
)
def test_with_preset(cmd, tmp_path: Path, presets: list[str], files: list[str]):
"""'init' command generate config file."""
proc = run([target_bin, "init"], stdout=PIPE, stderr=PIPE, text=True, cwd=tmp_path)
args = ["init", "--preset"] + presets
proc = cmd(*args)
assert proc.returncode == 0
assert (tmp_path / ".age.toml").exists()
#
age_toml = tmp_path / ".age.toml"
assert age_toml.exists()
age_text = age_toml.read_text()
assert 'current_version = "0.0.0"' in age_text
for f in files:
assert f'[[files]]\npath = "{f}"' in age_text

0 comments on commit cddd05a

Please sign in to comment.