source · Rust

Log

crates/vak-session/src/log.rs
Raw
80.7 KB2,022 lines75 anchorsSnapshot ed4ab258
  1. 2004 #[test]
  2. 2005 fn the_lock_lasts_exactly_as_long_as_the_handle() {
  3. 2006 let dir = tempfile::tempdir().unwrap();
  4. 2007 let path = dir.path().join("session.jsonl");
  5. 2008 std::fs::write(&path, "").unwrap();
  6. 2009
  7. 2010 let log = SessionLog::open(path.clone()).unwrap();
  8. 2011 assert!(matches!(
  9. 2012 SessionLog::open(path.clone()),
  10. 2013 Err(SessionError::Locked(_))
  11. 2014 ));
  12. 2015
  13. 2016 let duplicate = log.file.file.try_clone().unwrap();
  14. 2017 drop(log);
  15. 2018 SessionLog::open(path).expect("the dropped handle's lock stayed with a duplicate");
  16. 2019 drop(duplicate);
  17. 2020 }
  18. 2021}
  19. 2022