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

Function test_storage_file_ops_with_relative_paths

std/src/storage/mod.rs:1112–1140  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1110
1111 #[test]
1112 fn test_storage_file_ops_with_relative_paths() {
1113 let mut storage = Storage::default();
1114 storage.mount("other", "memory://").unwrap();
1115
1116 block_on(storage.put("/f1", b"some text")).unwrap();
1117 block_on(storage.put("f2", b"other text")).unwrap();
1118 {
1119 // Ensure that the put operations were routed to the correct objects.
1120 let memory_drive = storage.drives.get(&DriveKey::new("memory").unwrap()).unwrap();
1121 assert_eq!(2, block_on(memory_drive.drive.enumerate()).unwrap().dirents().len());
1122 let other_drive = storage.drives.get(&DriveKey::new("other").unwrap()).unwrap();
1123 assert_eq!(0, block_on(other_drive.drive.enumerate()).unwrap().dirents().len());
1124 }
1125
1126 assert_eq!(2, block_on(storage.enumerate("")).unwrap().dirents().len());
1127 assert_eq!(2, block_on(storage.enumerate("/")).unwrap().dirents().len());
1128 assert_eq!(0, block_on(storage.enumerate("other:")).unwrap().dirents().len());
1129 assert_eq!(0, block_on(storage.enumerate("other:/")).unwrap().dirents().len());
1130
1131 assert_eq!(b"some text", block_on(storage.get("f1")).unwrap().as_slice());
1132 assert_eq!(b"other text", block_on(storage.get("/f2")).unwrap().as_slice());
1133
1134 block_on(storage.delete("/f2")).unwrap();
1135 assert_eq!(1, block_on(storage.enumerate("")).unwrap().dirents().len());
1136 assert_eq!(0, block_on(storage.enumerate("other:")).unwrap().dirents().len());
1137 block_on(storage.delete("f1")).unwrap();
1138 assert_eq!(0, block_on(storage.enumerate("")).unwrap().dirents().len());
1139 assert_eq!(0, block_on(storage.enumerate("other:")).unwrap().dirents().len());
1140 }
1141
1142 #[test]
1143 fn test_storage_delete_errors() {

Callers

nothing calls this directly

Calls 4

mountMethod · 0.80
putMethod · 0.45
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected