MCPcopy Index your code
hub / github.com/endbasic/endbasic / test_get_files

Function test_get_files

client/src/cloud.rs:624–670  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

622 #[test]
623 #[ignore = "Requires environment configuration and is expensive"]
624 fn test_get_files() {
625 #[tokio::main]
626 async fn run(context: &mut TestContext) {
627 let username = context.do_login(1).await;
628
629 let mut needed_bytes = 0;
630 let mut needed_files = 0;
631 let mut filenames_and_contents = vec![];
632 for _ in 0..5 {
633 let (filename, content) = context.random_file();
634
635 needed_bytes += content.len() as u64;
636 needed_files += 1;
637 filenames_and_contents.push((filename, content));
638 }
639
640 let response = context.service.get_files(&username).await.unwrap();
641 for (filename, _content) in &filenames_and_contents {
642 assert!(!response.files.iter().any(|x| &x.filename == filename));
643 }
644 let disk_quota: DiskSpace = response.disk_quota.unwrap().into();
645 let disk_free: DiskSpace = response.disk_free.unwrap().into();
646 assert!(disk_quota.bytes() > 0);
647 assert!(disk_quota.files() > 0);
648 assert!(disk_free.bytes() >= needed_bytes, "Not enough space for test run");
649 assert!(disk_free.files() >= needed_files, "Not enough space for test run");
650
651 for (filename, _content) in &filenames_and_contents {
652 let err = context.service.get_file(&username, filename).await.unwrap_err();
653 assert_eq!(io::ErrorKind::NotFound, err.kind(), "{}", err);
654 }
655
656 for (filename, content) in &filenames_and_contents {
657 context
658 .service
659 .patch_file_content(&username, filename, content.clone())
660 .await
661 .unwrap();
662 }
663
664 let response = context.service.get_files(&username).await.unwrap();
665 for (filename, _content) in &filenames_and_contents {
666 assert!(response.files.iter().any(|x| &x.filename == filename));
667 }
668 }
669 run(&mut TestContext::new_from_env());
670 }
671
672 async fn do_get_and_patch_file_test<B: Into<Vec<u8>>>(
673 context: &mut TestContext,

Callers

nothing calls this directly

Calls 1

runFunction · 0.70

Tested by

no test coverage detected