MCPcopy Create free account
hub / github.com/endbasic/endbasic / test_webdrive_enumerate

Function test_webdrive_enumerate

web/src/store.rs:415–444  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

413
414 #[wasm_bindgen_test]
415 async fn test_webdrive_enumerate() {
416 let entry1 = Entry {
417 version: Entry::VERSION,
418 content: b"first".to_vec(),
419 mtime: OffsetDateTime::from_unix_timestamp(1234).unwrap(),
420 };
421 let entry2 = Entry {
422 version: Entry::VERSION,
423 content: b"second".to_vec(),
424 mtime: OffsetDateTime::from_unix_timestamp(987_654_321).unwrap(),
425 };
426
427 let webdrive = WebDrive::from_window();
428 webdrive.storage.clear().unwrap();
429 webdrive
430 .storage
431 .set("endbasic-program:FIRST.BAS", &serde_json::to_string(&entry1).unwrap())
432 .unwrap();
433 webdrive
434 .storage
435 .set("endbasic-program:SECOND SPACES.BAS", &serde_json::to_string(&entry2).unwrap())
436 .unwrap();
437 webdrive.storage.set("first.bas", "ignore me").unwrap();
438 webdrive.storage.set("endbasic-program:", "ignore me").unwrap();
439
440 let files = webdrive.enumerate().await.unwrap();
441 assert_eq!(2, files.dirents().len());
442 assert_eq!(&entry1.metadata(), files.dirents().get("FIRST.BAS").unwrap());
443 assert_eq!(&entry2.metadata(), files.dirents().get("SECOND SPACES.BAS").unwrap());
444 }
445
446 #[wasm_bindgen_test]
447 async fn test_webdrive_get() {

Callers

nothing calls this directly

Calls 3

setMethod · 0.80
clearMethod · 0.45
enumerateMethod · 0.45

Tested by

no test coverage detected