[FAST_BUILD] Test unset in run-hooks (#2022)

This commit is contained in:
Ayaz Salikhov
2023-11-04 11:34:33 +01:00
committed by GitHub
parent 9df3959137
commit d52ea4716e
4 changed files with 40 additions and 0 deletions

View File

@@ -127,3 +127,25 @@ def test_run_hooks_with_failures(container: TrackedContainer) -> None:
)
assert "OTHER_VAR=456" in logs
def test_run_hooks_unset(container: TrackedContainer) -> None:
host_data_dir = THIS_DIR / "run-hooks-unset"
cont_data_dir = "/home/jovyan/data"
# https://forums.docker.com/t/all-files-appear-as-executable-in-file-paths-using-bind-mount/99921
# Unfortunately, Docker treats all files in mounter dir as executable files
# So we make a copy of mounted dir inside a container
command = (
"cp -r /home/jovyan/data/ /home/jovyan/data-copy/ &&"
"source /usr/local/bin/run-hooks.sh /home/jovyan/data-copy/"
)
logs = container.run_and_wait(
timeout=5,
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
tty=True,
command=["bash", "-c", command],
)
assert "Inside a.sh MY_VAR variable has 123 value" in logs
assert "Inside b.sh MY_VAR variable has 123 value" in logs
assert "Unsetting MY_VAR" in logs
assert "Inside c.sh MY_VAR variable has value" in logs