MCPcopy Index your code
hub / github.com/enowdev/enowX-Coder / test_list_dir

Function test_list_dir

src-tauri/src/tools/executor.rs:854–882  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

852
853 #[tokio::test]
854 async fn test_list_dir() {
855 let sandbox_path = with_sandbox("list_dir");
856
857 tokio::fs::write(sandbox_path.join("file1.txt"), "a").await.unwrap();
858 tokio::fs::write(sandbox_path.join("file2.rs"), "b").await.unwrap();
859 tokio::fs::create_dir_all(sandbox_path.join("subdir")).await.unwrap();
860
861 let executor = ToolExecutor::new(sandbox_path);
862
863 let call = ToolCall {
864 tool: ToolName::ListDir,
865 input: serde_json::json!({ "path": "." }),
866 };
867 let result = executor.execute(call).await;
868 assert!(!result.is_error, "list_dir should succeed: {}", result.output);
869 assert!(result.output.contains("file1.txt"));
870 assert!(result.output.contains("file2.rs"));
871 assert!(result.output.contains("subdir"));
872
873 // Each entry should have [dir] or [file] prefix
874 for line in result.output.lines() {
875 assert!(
876 line.starts_with("[dir] ") || line.starts_with("[file] "),
877 "Unexpected line format: {line}"
878 );
879 }
880
881 cleanup("list_dir");
882 }
883
884 #[tokio::test]
885 async fn test_list_dir_path_traversal_attack() {

Callers

nothing calls this directly

Calls 3

with_sandboxFunction · 0.85
cleanupFunction · 0.85
executeMethod · 0.80

Tested by

no test coverage detected