diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-05-10 05:51:39 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-05-10 05:51:39 +0000 |
commit | 9d93e77ed08b086b705f3c6d52e6f936dc337ade (patch) | |
tree | b04294a85b4bcfb540107e39490018e8f42d5a6f /src/generation.rs | |
parent | 0b6adba069cd1300079c822b14832d690595cfb4 (diff) | |
parent | 4913347201f4d00ccaf959c53357241d5bc3f9e0 (diff) | |
download | obnam2-9d93e77ed08b086b705f3c6d52e6f936dc337ade.tar.gz |
Merge branch 'liw/integer-test' into 'main'
add tests for storing max integers (change FileId to signed)
Closes #188
See merge request obnam/obnam!231
Diffstat (limited to 'src/generation.rs')
-rw-r--r-- | src/generation.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/generation.rs b/src/generation.rs index 180efbe..477edc0 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -296,8 +296,33 @@ impl LocalGeneration { #[cfg(test)] mod test { - use super::{LabelChecksumKind, LocalGeneration, NascentGeneration, SchemaVersion}; - use tempfile::NamedTempFile; + use super::{LabelChecksumKind, LocalGeneration, NascentGeneration, Reason, SchemaVersion}; + use crate::fsentry::EntryBuilder; + use crate::fsentry::FilesystemKind; + use std::path::PathBuf; + use tempfile::{tempdir, NamedTempFile}; + + #[test] + fn round_trips_u64_max() { + let tmp = tempdir().unwrap(); + let filename = tmp.path().join("test.db"); + let path = PathBuf::from("/"); + let schema = SchemaVersion::new(0, 0); + { + let e = EntryBuilder::new(FilesystemKind::Directory) + .path(path.clone()) + .len(u64::MAX) + .build(); + let mut gen = + NascentGeneration::create(&filename, schema, LabelChecksumKind::Sha256).unwrap(); + gen.insert(e, &[], Reason::IsNew, false).unwrap(); + gen.close().unwrap(); + } + + let db = LocalGeneration::open(&filename).unwrap(); + let e = db.get_file(&path).unwrap().unwrap(); + assert_eq!(e.len(), u64::MAX); + } #[test] fn empty() { |