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.

overflowing deletes maxes out

+38
+38
ufos/src/lib.rs
··· 318 318 319 319 Ok(()) 320 320 } 321 + 322 + #[test] 323 + fn test_truncating_insert_maxes_out_deletes() -> anyhow::Result<()> { 324 + let mut commits: CollectionCommits<2> = Default::default(); 325 + 326 + commits.truncating_insert(UFOsCommit { 327 + cursor: Cursor::from_raw_u64(100), 328 + did: Did::new("did:plc:whatever".to_string()).unwrap(), 329 + rkey: RecordKey::new("rkey-asdf-a".to_string()).unwrap(), 330 + rev: "rev-asdf".to_string(), 331 + action: CommitAction::Cut, 332 + }).unwrap(); 333 + 334 + commits.truncating_insert(UFOsCommit { 335 + cursor: Cursor::from_raw_u64(101), 336 + did: Did::new("did:plc:whatever".to_string()).unwrap(), 337 + rkey: RecordKey::new("rkey-asdf-b".to_string()).unwrap(), 338 + rev: "rev-asdg".to_string(), 339 + action: CommitAction::Cut, 340 + }).unwrap(); 341 + 342 + let res = commits.truncating_insert(UFOsCommit { 343 + cursor: Cursor::from_raw_u64(102), 344 + did: Did::new("did:plc:whatever".to_string()).unwrap(), 345 + rkey: RecordKey::new("rkey-asdf-c".to_string()).unwrap(), 346 + rev: "rev-asdh".to_string(), 347 + action: CommitAction::Cut, 348 + }); 349 + 350 + assert!(res.is_err()); 351 + let overflowed = match res { 352 + Err(BatchInsertError::BatchFull(c)) => c, 353 + e => panic!("expected overflow but a different error happened: {e:?}"), 354 + }; 355 + assert_eq!(overflowed.rev, "rev-asdh"); 356 + 357 + Ok(()) 358 + } 321 359 }