mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-12-24 18:01:04 +01:00
Run tests with and without direnv’s strict_env
It seems unlikely that the “without” case will have any errors that the “with” case doesn’t, but it’s still a common use case and easy enough to parametrize.
This commit is contained in:
parent
857bcd5c4f
commit
92eb25521e
3 changed files with 25 additions and 15 deletions
|
|
@ -4,6 +4,7 @@ import sys
|
|||
import unittest
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
from direnv_project import DirenvProject
|
||||
from procs import run
|
||||
|
||||
|
|
@ -28,25 +29,29 @@ def direnv_exec(
|
|||
assert "renewed cache" in out.stderr
|
||||
|
||||
|
||||
def test_attrs(direnv_project: DirenvProject) -> None:
|
||||
direnv_project.setup_envrc("use nix -A subshell")
|
||||
@pytest.mark.parametrize("strict_env", [False, True])
|
||||
def test_attrs(direnv_project: DirenvProject, strict_env: bool) -> None:
|
||||
direnv_project.setup_envrc("use nix -A subshell", strict_env=strict_env)
|
||||
direnv_exec(direnv_project, "echo $THIS_IS_A_SUBSHELL")
|
||||
|
||||
|
||||
def test_no_nix_path(direnv_project: DirenvProject) -> None:
|
||||
direnv_project.setup_envrc("use nix --argstr someArg OK")
|
||||
@pytest.mark.parametrize("strict_env", [False, True])
|
||||
def test_no_nix_path(direnv_project: DirenvProject, strict_env: bool) -> None:
|
||||
direnv_project.setup_envrc("use nix --argstr someArg OK", strict_env=strict_env)
|
||||
env = os.environ.copy()
|
||||
del env["NIX_PATH"]
|
||||
direnv_exec(direnv_project, "echo $SHOULD_BE_SET", env=env)
|
||||
|
||||
|
||||
def test_args(direnv_project: DirenvProject) -> None:
|
||||
direnv_project.setup_envrc("use nix --argstr someArg OK")
|
||||
@pytest.mark.parametrize("strict_env", [False, True])
|
||||
def test_args(direnv_project: DirenvProject, strict_env: bool) -> None:
|
||||
direnv_project.setup_envrc("use nix --argstr someArg OK", strict_env=strict_env)
|
||||
direnv_exec(direnv_project, "echo $SHOULD_BE_SET")
|
||||
|
||||
|
||||
def test_no_files(direnv_project: DirenvProject) -> None:
|
||||
direnv_project.setup_envrc("use nix -p hello")
|
||||
@pytest.mark.parametrize("strict_env", [False, True])
|
||||
def test_no_files(direnv_project: DirenvProject, strict_env: bool) -> None:
|
||||
direnv_project.setup_envrc("use nix -p hello", strict_env=strict_env)
|
||||
out = run(
|
||||
["direnv", "status"],
|
||||
stderr=subprocess.PIPE,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue