Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic unit tests for operations #81

Merged
merged 17 commits into from
Jan 8, 2025
Merged
Prev Previous commit
Next Next commit
Simple test for ls op
  • Loading branch information
debonte committed Dec 12, 2024
commit 21724f1752c847465c8f4a2164002a030a48db36
23 changes: 23 additions & 0 deletions tests/ops/ls/test_ls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import tempfile

from sarif.operations import ls_op


def test_ls():
file_names = ["file1.sarif", "file2.sarif", "aaaa.sarif"]

with tempfile.TemporaryDirectory() as tmp:
for file_name in file_names:
with open(os.path.join(tmp, file_name), "wb") as f_in:
f_in.write("{}".encode())

output_path = os.path.join(tmp, "output.txt")
ls_op.print_ls([tmp], output_path)

with open(output_path, "rb") as f_out:
output = f_out.read().decode().splitlines()

assert len(output) == len(file_names) + 1
assert output[0] == tmp + ":"
assert output[1:] == sorted([" " + file_name for file_name in file_names])