MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / test_path_ops

Function test_path_ops

crates/chat-cli/src/cli/chat/context.rs:408–438  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

406
407 #[tokio::test]
408 async fn test_path_ops() -> Result<()> {
409 let os = Os::new().await.unwrap();
410 let mut manager = create_test_context_manager(None).expect("Failed to create test context manager");
411
412 // Create some test files for matching.
413 os.fs.create_dir_all("test").await?;
414 os.fs.write("test/p1.md", "p1").await?;
415 os.fs.write("test/p2.md", "p2").await?;
416
417 assert!(
418 manager.get_context_files(&os).await?.is_empty(),
419 "no files should be returned for an empty profile when force is false"
420 );
421
422 manager.add_paths(&os, vec!["test/*.md".to_string()], false).await?;
423 let files = manager.get_context_files(&os).await?;
424 assert!(files[0].0.ends_with("p1.md"));
425 assert_eq!(files[0].1, "p1");
426 assert!(files[1].0.ends_with("p2.md"));
427 assert_eq!(files[1].1, "p2");
428
429 assert!(
430 manager
431 .add_paths(&os, vec!["test/*.txt".to_string()], false)
432 .await
433 .is_err(),
434 "adding a glob with no matching and without force should fail"
435 );
436
437 Ok(())
438 }
439
440 #[test]
441 fn test_calc_max_context_files_size() {

Callers

nothing calls this directly

Calls 5

create_dir_allMethod · 0.80
add_pathsMethod · 0.80
get_context_filesMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected