Files
onyx-cli/test_exe.py
T

49 lines
1.4 KiB
Python

import subprocess
import shutil
from pathlib import Path
import sys
def test_exe():
exe_path = Path('dist/onyx.exe').resolve()
if not exe_path.exists():
print(f"Executable not found at {exe_path}")
sys.exit(1)
test_dir = Path('test_vault_exe')
if test_dir.exists():
shutil.rmtree(test_dir)
test_dir.mkdir()
print(f"Testing executable: {exe_path}")
# Set default vault
cmd = [str(exe_path), 'set-default', 'test_vault_exe', '--path', str(test_dir.resolve())]
print(f"Running: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
# Create note without extension
cmd = [str(exe_path), 'create', 'exe_note1', '--content', 'content']
print(f"Running: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
if (test_dir / 'exe_note1.md').exists():
print("PASS: exe_note1.md created")
else:
print("FAIL: exe_note1.md NOT created")
# Create note with .txt extension
cmd = [str(exe_path), 'create', 'exe_note2.txt', '--content', 'content']
print(f"Running: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
if (test_dir / 'exe_note2.txt.md').exists():
print("PASS: exe_note2.txt.md created")
else:
print("FAIL: exe_note2.txt.md NOT created")
# Cleanup
shutil.rmtree(test_dir)
if __name__ == "__main__":
test_exe()