MCPcopy Create free account
hub / github.com/wonderwhy-er/DesktopCommanderMCP / testInvalidPath

Function testInvalidPath

test/test-search-code.js:411–432  ·  view source on GitHub ↗

* Test invalid path handling

()

Source from the content-addressed store, hash-verified

409 * Test invalid path handling
410 */
411async function testInvalidPath() {
412 console.log(`${colors.yellow}Testing invalid path handling...${colors.reset}`);
413
414 try {
415 const result = await handleStartSearch({
416 path: '/nonexistent/path/that/does/not/exist',
417 pattern: 'pattern',
418 searchType: 'content'
419 });
420
421 // Should handle gracefully
422 assert(result.content, 'Result should have content');
423 const text = result.content[0].text;
424 const isValidResponse = text.includes('Error') || text.includes('session:') || text.includes('not allowed');
425 assert(isValidResponse, 'Should handle invalid path gracefully');
426
427 console.log(`${colors.green}✓ Invalid path test passed${colors.reset}`);
428 } catch (error) {
429 // It's also acceptable for the function to throw an error for invalid paths
430 console.log(`${colors.green}✓ Invalid path test passed (threw error as expected)${colors.reset}`);
431 }
432}
433
434/**
435 * Test schema validation with invalid arguments

Callers 1

testSearchCodeFunction · 0.85

Calls 3

handleStartSearchFunction · 0.85
logMethod · 0.80
assertFunction · 0.70

Tested by

no test coverage detected