Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
0

Configure Feed

Select the types of activity you want to include in your feed.

failing test: panic on unwrap

either the iterator bounds aren't set up right, or the prefix thing is a little wrong

+164 -3
+3 -3
ufos/src/lib.rs
··· 277 277 }, 278 278 } 279 279 280 - #[derive(Debug, Serialize, JsonSchema)] 280 + #[derive(Debug, PartialEq, Serialize, JsonSchema)] 281 281 pub struct NsidCount { 282 282 nsid: String, 283 283 creates: u64, ··· 285 285 dids_estimate: u64, 286 286 } 287 287 288 - #[derive(Debug, Serialize, JsonSchema)] 288 + #[derive(Debug, PartialEq, Serialize, JsonSchema)] 289 289 pub struct PrefixCount { 290 290 prefix: String, 291 291 creates: u64, ··· 293 293 dids_estimate: u64, 294 294 } 295 295 296 - #[derive(Debug, Serialize, JsonSchema)] 296 + #[derive(Debug, PartialEq, Serialize, JsonSchema)] 297 297 #[serde(tag = "type", rename_all = "camelCase")] 298 298 pub enum PrefixChild { 299 299 Collection(NsidCount),
+161
ufos/src/storage_fjall.rs
··· 2466 2466 2467 2467 Ok(()) 2468 2468 } 2469 + 2470 + #[test] 2471 + fn get_nsid_prefix_children_lexi_empty() { 2472 + let (read, _) = fjall_db(); 2473 + let ( 2474 + JustCount { 2475 + creates, 2476 + dids_estimate, 2477 + .. 2478 + }, 2479 + children, 2480 + cursor, 2481 + ) = read 2482 + .get_prefix( 2483 + NsidPrefix::new("aaa.aaa").unwrap(), 2484 + 10, 2485 + OrderCollectionsBy::Lexi { cursor: None }, 2486 + None, 2487 + None, 2488 + ) 2489 + .unwrap(); 2490 + 2491 + assert_eq!(creates, 0); 2492 + assert_eq!(dids_estimate, 0); 2493 + assert_eq!(children, vec![]); 2494 + assert_eq!(cursor, None); 2495 + } 2496 + 2497 + #[test] 2498 + fn get_nsid_prefix_children_lexi() -> anyhow::Result<()> { 2499 + let (read, mut write) = fjall_db(); 2500 + 2501 + let mut batch = TestBatch::default(); 2502 + batch.create( 2503 + "did:plc:person-a", 2504 + "a.a.a", 2505 + "rkey-aaa", 2506 + "{}", 2507 + Some("rev-aaa"), 2508 + None, 2509 + 10_000, 2510 + ); 2511 + batch.create( 2512 + "did:plc:person-a", 2513 + "a.a.a.a", 2514 + "rkey-aaaa", 2515 + "{}", 2516 + Some("rev-aaaa"), 2517 + None, 2518 + 10_001, 2519 + ); 2520 + batch.create( 2521 + "did:plc:person-b", 2522 + "a.a.a.a", 2523 + "rkey-aaaa", 2524 + "{}", 2525 + Some("rev-aaaa"), 2526 + None, 2527 + 10_002, 2528 + ); 2529 + batch.create( 2530 + "did:plc:person-a", 2531 + "a.a.a.c", 2532 + "rkey-aaac", 2533 + "{}", 2534 + Some("rev-aaac"), 2535 + None, 2536 + 10_003, 2537 + ); 2538 + batch.create( 2539 + "did:plc:person-b", 2540 + "a.b.c.d", 2541 + "rkey-abcd", 2542 + "{}", 2543 + Some("rev-abcd"), 2544 + None, 2545 + 10_004, 2546 + ); 2547 + batch.create( 2548 + "did:plc:person-a", 2549 + "w.x.y.z", 2550 + "rkey-wxyz", 2551 + "{}", 2552 + Some("rev-wxyz"), 2553 + None, 2554 + 10_005, 2555 + ); 2556 + write.insert_batch(batch.batch)?; 2557 + 2558 + write.step_rollup()?; 2559 + 2560 + let ( 2561 + JustCount { 2562 + creates, 2563 + dids_estimate, 2564 + .. 2565 + }, 2566 + children, 2567 + cursor, 2568 + ) = read.get_prefix( 2569 + NsidPrefix::new("a.a").unwrap(), 2570 + 10, 2571 + OrderCollectionsBy::Lexi { cursor: None }, 2572 + None, 2573 + None, 2574 + )?; 2575 + assert_eq!(creates, 4); 2576 + assert_eq!(dids_estimate, 2); 2577 + assert_eq!( 2578 + children, 2579 + vec![ 2580 + PrefixChild::Collection(NsidCount { 2581 + nsid: "a.a.a".to_string(), 2582 + creates: 1, 2583 + dids_estimate: 1 2584 + }), 2585 + PrefixChild::Prefix(PrefixCount { 2586 + prefix: "a.a.a".to_string(), 2587 + creates: 3, 2588 + dids_estimate: 2 2589 + }), 2590 + ] 2591 + ); 2592 + assert_eq!(cursor, None); 2593 + 2594 + let ( 2595 + JustCount { 2596 + creates, 2597 + dids_estimate, 2598 + .. 2599 + }, 2600 + children, 2601 + cursor, 2602 + ) = read.get_prefix( 2603 + NsidPrefix::new("a.a.a").unwrap(), 2604 + 10, 2605 + OrderCollectionsBy::Lexi { cursor: None }, 2606 + None, 2607 + None, 2608 + )?; 2609 + assert_eq!(creates, 4); 2610 + assert_eq!(dids_estimate, 2); 2611 + assert_eq!( 2612 + children, 2613 + vec![ 2614 + PrefixChild::Collection(NsidCount { 2615 + nsid: "a.a.a".to_string(), 2616 + creates: 1, 2617 + dids_estimate: 1 2618 + }), 2619 + PrefixChild::Prefix(PrefixCount { 2620 + prefix: "a.a.a".to_string(), 2621 + creates: 3, 2622 + dids_estimate: 2 2623 + }), 2624 + ] 2625 + ); 2626 + assert_eq!(cursor, None); 2627 + 2628 + Ok(()) 2629 + } 2469 2630 }