Enhance test coverage by adding new cases for file listing, reading, and ripgrep functionalities. Implement tests for hidden files, depth handling, and path normalization in list_files tests. Expand read_file tests to cover line skipping and reading from empty files. Improve ripgrep tests with various pattern matching scenarios, including regex handling and file pattern exclusions.

This commit is contained in:
sebseb7
2025-08-11 23:07:59 +02:00
parent 15d8e96b49
commit b91c4bf5e7
4 changed files with 133 additions and 0 deletions

View File

@@ -114,6 +114,38 @@ function cases() {
expect: { equals: Array.from({ length: 400 }, (_, i) => `L${i + 1}`).join('\n') }
});
// 7. Skip beyond file length -> empty
list.push({
name: 'skip beyond length returns empty',
before: { 's.txt': 'A\nB' },
args: async ({ dir }) => ({ path: path.relative(chrootRoot, path.join(dir, 's.txt')), linesToSkip: 10, linesToRead: 5 }),
expect: { equals: '' }
});
// 8. Skip to last line and read one
list.push({
name: 'skip to last line and read one',
before: { 't.txt': 'L1\nL2\nL3' },
args: async ({ dir }) => ({ path: path.relative(chrootRoot, path.join(dir, 't.txt')), linesToSkip: 2, linesToRead: 1 }),
expect: { equals: 'L3' }
});
// 9. Read exactly N lines from middle
list.push({
name: 'read middle two lines',
before: { 'u.txt': 'A\nB\nC\nD' },
args: async ({ dir }) => ({ path: path.relative(chrootRoot, path.join(dir, 'u.txt')), linesToSkip: 1, linesToRead: 2 }),
expect: { equals: 'B\nC' }
});
// 10. Empty file read -> empty string
list.push({
name: 'empty file read',
before: { 'empty.txt': '' },
args: async ({ dir }) => ({ path: path.relative(chrootRoot, path.join(dir, 'empty.txt')), linesToSkip: 0, linesToRead: 100 }),
expect: { equals: '' }
});
return list;
}