Skip to content

Commit 73727f3

Browse files
committed
Make more hook tests pass
1 parent 6b96076 commit 73727f3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

images/docker-stacks-foundation/run-hooks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ def source(path: PosixPath):
8686

8787
if not hooks_directory.exists():
8888
print(f"Directory {hooks_directory} does not exist")
89+
sys.exit(1)
8990

9091
if not hooks_directory.is_dir():
9192
print(f"{hooks_directory} is not a directory")
93+
sys.exit(1)
9294

9395
print(f"Running hooks in: {hooks_directory} as {os.getuid()} gid: {os.getgid()}")
9496

@@ -104,9 +106,7 @@ def source(path: PosixPath):
104106
f"{f} has failed with return code {run.returncode}, continuing execution"
105107
)
106108
else:
107-
print(f"Ignoring non-executable file {f}")
109+
print(f"Ignoring non-executable: {f}")
108110

109111

110112
print(f"Done running hooks in: {hooks_directory}")
111-
112-
print(os.environ['HELLO'])

tests/docker-stacks-foundation/test_run_hooks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_run_hooks_missing_dir(container: TrackedContainer) -> None:
4444
"source /usr/local/bin/run-hooks.sh /tmp/missing-dir/",
4545
],
4646
)
47-
assert "Directory /tmp/missing-dir/ doesn't exist or is not a directory" in logs
47+
assert "Directory /tmp/missing-dir does not exist" in logs
4848

4949

5050
def test_run_hooks_dir_is_file(container: TrackedContainer) -> None:
@@ -58,7 +58,7 @@ def test_run_hooks_dir_is_file(container: TrackedContainer) -> None:
5858
"touch /tmp/some-file && source /usr/local/bin/run-hooks.sh /tmp/some-file",
5959
],
6060
)
61-
assert "Directory /tmp/some-file doesn't exist or is not a directory" in logs
61+
assert "/tmp/some-file is not a directory" in logs
6262

6363

6464
def test_run_hooks_empty_dir(container: TrackedContainer) -> None:
@@ -91,7 +91,7 @@ def test_run_hooks_with_files(container: TrackedContainer) -> None:
9191
command=["bash", "-c", command],
9292
)
9393
assert "Executable python file was successfully" in logs
94-
assert "Ignoring non-executable: /home/jovyan/data-copy//non_executable.py" in logs
94+
assert "Ignoring non-executable: /home/jovyan/data-copy/non_executable.py" in logs
9595
assert "SOME_VAR is 123" in logs
9696

9797

0 commit comments

Comments
 (0)