Files
gpu-rent/tests/test_varsfile.py
Leonid Pershin a9cf2e0f90 Add support for gpu-rent.vars and enhance git update functionality
- Updated .gitignore to include gpu-rent.vars.
- Modified env.example to introduce the UPDATE_GIT variable for controlling git updates during execution.
- Implemented Import-GpuRentVars function in gpu-rent.ps1 to load environment variables from gpu-rent.vars.
- Enhanced gpu-rent.sh to support loading variables from gpu-rent.vars and added logic for handling default and extra arguments.
- Updated CLI documentation to reflect the new gpu-rent.vars file and its usage in configuration.
- Improved bootstrap and provisioning logic to conditionally perform git updates based on the new configuration.
2026-08-21 05:01:53 +03:00

33 lines
968 B
Python

from pathlib import Path
from gpu_rent.varsfile import apply_vars_file, parse_vars_file, split_args
def test_parse_vars_file(tmp_path: Path):
path = tmp_path / "gpu-rent.vars"
path.write_text(
"# comment\n"
"GPU_RENT_DEFAULT_ARGS=up --yes\n"
"export UPDATE_GIT=false\n"
"QUOTED=\"a b\"\n",
encoding="utf-8",
)
data = parse_vars_file(path)
assert data["GPU_RENT_DEFAULT_ARGS"] == "up --yes"
assert data["UPDATE_GIT"] == "false"
assert data["QUOTED"] == "a b"
def test_apply_does_not_override(tmp_path: Path, monkeypatch):
path = tmp_path / "gpu-rent.vars"
path.write_text("FOO=from-file\n", encoding="utf-8")
monkeypatch.setenv("FOO", "from-env")
apply_vars_file(path, override=False)
import os
assert os.environ["FOO"] == "from-env"
def test_split_args():
assert split_args("up --yes --no-update") == ["up", "--yes", "--no-update"]