Skip to content
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9784673
🧪 Add tests for scanner stat errors and large files
seonghobae Jun 16, 2026
3cc4606
🧪 Add tests for scanner stat errors and large files
seonghobae Jun 16, 2026
a309f58
Merge origin/develop into jules-2070900741305223408-e636d098
Copilot Jun 16, 2026
153773a
Merge remote-tracking branch 'origin/jules-2070900741305223408-e636d0…
Copilot Jun 16, 2026
82a32be
🧪 Add tests for scanner stat errors and large files
seonghobae Jun 16, 2026
0c9c7e2
🧪 Add tests for scanner stat errors and large files
seonghobae Jun 16, 2026
ae8066c
Merge develop into test PR branch
Copilot Jun 16, 2026
3af2cda
Merge remote PR branch after conflict resolution
Copilot Jun 16, 2026
cb0111b
🧪 Add tests for scanner stat errors and large files
seonghobae Jun 16, 2026
de23306
Restore PR scope to scanner tests
Copilot Jun 16, 2026
092cc44
🧪 Add tests for scanner stat errors and large files
seonghobae Jun 16, 2026
c04a495
Polish scanner test names
Copilot Jun 16, 2026
239b37b
Tidy scanner test formatting
Copilot Jun 16, 2026
a843dd8
Split scanner stat error tests
Copilot Jun 16, 2026
c50a7f9
Shorten scanner test names
Copilot Jun 16, 2026
81bf8fd
Align scanner test naming
Copilot Jun 16, 2026
0333e52
Merge remote-tracking branch 'origin/jules-2070900741305223408-e636d0…
Copilot Jun 16, 2026
24e9560
Restore scanner test coverage after branch sync
Copilot Jun 16, 2026
7ad1ddf
Restore PR files to base branch state
Copilot Jun 16, 2026
5c05d2f
Merge develop into PR branch
Copilot Jun 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions tests/test_vibesec.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ def test_collect_files_handles_cyclic_symlink(tmp_path):
assert collected_rel_paths == {"a/a.py", "b/b.py"}


def test_collect_files_handles_oserror_in_scandir(tmp_path):
def test_collect_files_scandir_permission_error(tmp_path):
(tmp_path / "a.py").touch()
with patch("os.scandir", side_effect=PermissionError):
assert list(_collect_files(tmp_path)) == []


def test_collect_files_handles_oserror_in_entry(tmp_path):
def test_collect_files_permission_error_entry(tmp_path):
(tmp_path / "a.py").touch()
(tmp_path / "b.py").touch()

Expand Down Expand Up @@ -251,8 +251,6 @@ def is_symlink(self):
collected_rel_paths = {f.relative_to(tmp_path).as_posix() for f in _collect_files(tmp_path)}
assert collected_rel_paths == {"b.py"}



@patch("scanner.cli.vibesec.SCAN_RULES", MOCK_RULES)
def test_scan_file_skips_symlink(tmp_path):
target = tmp_path / "target.py"
Expand Down Expand Up @@ -468,6 +466,24 @@ def test_print_supabase_reminder(capsys):
assert "Keep SUPABASE_SERVICE_ROLE_KEY server-side only" in captured.out


def test_scan_file_permission_error(tmp_path):
test_file = tmp_path / "permission_error.ts"
test_file.write_text("const key = 'x';\n")

with patch("scanner.cli.vibesec.os.lstat", side_effect=PermissionError("Permission denied")) as mock_permission:
assert _scan_file(test_file, tmp_path) == []
mock_permission.assert_called_once()


def test_scan_file_os_error(tmp_path):
test_file = tmp_path / "os_error.ts"
test_file.write_text("const key = 'x';\n")

with patch("scanner.cli.vibesec.os.lstat", side_effect=OSError("OS error")) as mock_oserror:
assert _scan_file(test_file, tmp_path) == []
mock_oserror.assert_called_once()


def test_collect_files_oserror_on_scandir(tmp_path):
(tmp_path / "dir1").mkdir()
(tmp_path / "dir1" / "file1.py").touch()
Expand Down Expand Up @@ -587,3 +603,31 @@ def test_cmd_review_all_options(capsys):
assert REVIEW_PROMPT_SUPABASE in captured.out
assert REVIEW_PROMPT_STRIPE in captured.out
assert REVIEW_PROMPT_FOOTER in captured.out


def test_scan_file_large_file(tmp_path):
test_file = tmp_path / "large_file.ts"
test_file.write_text("const key = 'x';\n")

original_lstat = os.lstat

def mock_lstat(path):
st = original_lstat(path)
return os.stat_result(
(
st.st_mode,
st.st_ino,
st.st_dev,
st.st_nlink,
st.st_uid,
st.st_gid,
10 * 1024 * 1024 + 1,
st.st_atime,
st.st_mtime,
st.st_ctime,
)
)

with patch("scanner.cli.vibesec.os.lstat", side_effect=mock_lstat) as mock_large:
assert _scan_file(test_file, tmp_path) == []
mock_large.assert_called_once()
Loading