mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
- Change --log flag to require explicit log directory (--log <LOG_DIR>) - Automatically create log directory with parents=True - Harden permissions best-effort (0700) - Update CLI help text accordingly - Adjust Makefile test targets to pass explicit log directory - Ignore logs/ via .gitignore and .dockerignore - Refactor flag parsing to correctly detect deploy with --log - Add dedicated logging unit tests - Update existing tests for new log semantics - Remove deprecated -i alias for --id in deploy command https://chatgpt.com/share/6969680a-dbf8-800f-aafb-3d32d6212ba0
32 lines
903 B
Python
32 lines
903 B
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from cli.core.run import open_log_file
|
|
|
|
|
|
class TestLogging(unittest.TestCase):
|
|
def test_open_log_file_creates_parents_and_writes(self):
|
|
with tempfile.TemporaryDirectory() as td:
|
|
# nested path to ensure parents=True behavior is exercised
|
|
log_dir = Path(td) / "a" / "b" / "c" / "logs"
|
|
|
|
self.assertFalse(log_dir.exists())
|
|
f, path = open_log_file(log_dir)
|
|
try:
|
|
self.assertTrue(log_dir.exists())
|
|
self.assertTrue(path.exists())
|
|
self.assertIn(log_dir, path.parents)
|
|
|
|
f.write("hello\n")
|
|
f.flush()
|
|
|
|
content = path.read_text(encoding="utf-8")
|
|
self.assertIn("hello", content)
|
|
finally:
|
|
f.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|