MCPcopy Create free account
hub / github.com/apache/datafusion / test_list_files

Function test_list_files

datafusion/datasource/src/url.rs:748–839  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

746
747 #[tokio::test]
748 async fn test_list_files() -> Result<()> {
749 let store = MockObjectStore {
750 in_mem: object_store::memory::InMemory::new(),
751 forbidden_paths: vec!["forbidden/e.parquet".into()],
752 };
753
754 // Create some files:
755 create_file(&store, "a.parquet").await;
756 create_file(&store, "/t/b.parquet").await;
757 create_file(&store, "/t/c.csv").await;
758 create_file(&store, "/t/d.csv").await;
759
760 // This file returns a permission error.
761 create_file(&store, "/forbidden/e.parquet").await;
762
763 assert_eq!(
764 list_all_files("/", &store, "parquet").await?,
765 vec!["a.parquet"],
766 );
767
768 // test with and without trailing slash
769 assert_eq!(
770 list_all_files("/t/", &store, "parquet").await?,
771 vec!["t/b.parquet"],
772 );
773 assert_eq!(
774 list_all_files("/t", &store, "parquet").await?,
775 vec!["t/b.parquet"],
776 );
777
778 // test with and without trailing slash
779 assert_eq!(
780 list_all_files("/t", &store, "csv").await?,
781 vec!["t/c.csv", "t/d.csv"],
782 );
783 assert_eq!(
784 list_all_files("/t/", &store, "csv").await?,
785 vec!["t/c.csv", "t/d.csv"],
786 );
787
788 // Test a non existing prefix
789 assert_eq!(
790 list_all_files("/NonExisting", &store, "csv").await?,
791 vec![] as Vec<String>
792 );
793 assert_eq!(
794 list_all_files("/NonExisting/", &store, "csv").await?,
795 vec![] as Vec<String>
796 );
797
798 // Including forbidden.parquet generates an error.
799 let Err(DataFusionError::ObjectStore(err)) =
800 list_all_files("/forbidden/e.parquet", &store, "parquet").await
801 else {
802 panic!("Expected ObjectStore error");
803 };
804
805 let object_store::Error::PermissionDenied { .. } = &*err else {

Callers

nothing calls this directly

Calls 3

newFunction · 0.85
list_all_filesFunction · 0.85
create_fileFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…