]> git.proxmox.com Git - pxar.git/commitdiff
tests: cleanup warnings
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 26 Jun 2020 09:20:45 +0000 (11:20 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 26 Jun 2020 09:20:45 +0000 (11:20 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
tests/simple/fs.rs
tests/simple/main.rs

index d4ba163f7a14521b63d4841daf9e6c3b0790900a..6598eb40ffa090d9a7b9c719e81a731268df7209 100644 (file)
@@ -8,7 +8,7 @@ use pxar::decoder::sync as decoder;
 use pxar::decoder::SeqRead;
 use pxar::encoder::sync as encoder;
 use pxar::encoder::{LinkOffset, SeqWrite};
-use pxar::format::{self, mode, Device};
+use pxar::format::{mode, Device};
 use pxar::EntryKind as PxarEntryKind;
 use pxar::Metadata;
 
@@ -179,8 +179,6 @@ impl Entry {
                 self.no_hardlink()?;
                 let _: () = encoder.add_socket(&self.metadata, &self.name)?;
             }
-
-            other => bail!("TODO: encode_entry for {:?}", other),
         }
         Ok(())
     }
@@ -239,6 +237,14 @@ impl Entry {
                             format_err!("failed to get contents for file entry: {:?}", item.path())
                         })?
                         .read_to_end(&mut data)?;
+                    if data.len() as u64 != *size {
+                        bail!(
+                            "file {:?} was advertised to be of size {} but we read {} bytes",
+                            item.path(),
+                            size,
+                            data.len(),
+                        );
+                    }
                     contents.push(make_entry()?.entry(EntryKind::File(data)));
                 }
                 PxarEntryKind::Directory => {
@@ -270,7 +276,6 @@ impl Entry {
                 PxarEntryKind::Socket => {
                     contents.push(make_entry()?.entry(EntryKind::Socket));
                 }
-                other => todo!("decode for kind {:?}", other),
             }
         }
 
index 88e5900341842b348097ad053335d67d0af3c0ed..337c7fa48305029ee0c7ed3710bf9cd37924a957 100644 (file)
@@ -33,7 +33,9 @@ fn test1() {
     let mut encoder =
         encoder::Encoder::from_std(&mut file, &test_fs.metadata).expect("failed to create encoder");
     encode_directory(&mut encoder, &test_fs).expect("failed to encode test file system");
-    encoder.finish();
+    encoder
+        .finish()
+        .expect("failed to finish encoding the pxar archive");
 
     assert!(!file.is_empty(), "encoder did not write any data");