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

Function test_read_to_string

crates/chat-cli/src/os/fs/mod.rs:506–546  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

504
505 #[tokio::test]
506 async fn test_read_to_string() {
507 let fs = Fs::new();
508 fs.write("fake", "contents").await.unwrap();
509 fs.write("invalid_utf8", &[255]).await.unwrap();
510
511 // async tests
512 assert_eq!(
513 fs.read_to_string("fake").await.unwrap(),
514 "contents",
515 "should read fake file"
516 );
517 assert!(
518 fs.read_to_string("unknown")
519 .await
520 .is_err_and(|err| err.kind() == io::ErrorKind::NotFound),
521 "unknown path should return NotFound"
522 );
523 assert!(
524 fs.read_to_string("invalid_utf8")
525 .await
526 .is_err_and(|err| err.kind() == io::ErrorKind::InvalidData),
527 "invalid utf8 should return InvalidData"
528 );
529
530 // sync tests
531 assert_eq!(
532 fs.read_to_string_sync("fake").unwrap(),
533 "contents",
534 "should read fake file"
535 );
536 assert!(
537 fs.read_to_string_sync("unknown")
538 .is_err_and(|err| err.kind() == io::ErrorKind::NotFound),
539 "unknown path should return NotFound"
540 );
541 assert!(
542 fs.read_to_string_sync("invalid_utf8")
543 .is_err_and(|err| err.kind() == io::ErrorKind::InvalidData),
544 "invalid utf8 should return InvalidData"
545 );
546 }
547
548 #[tokio::test]
549 #[cfg(unix)]

Callers

nothing calls this directly

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected