Skip to content

Commit

Permalink
Merge pull request #600 from cgwalters/more-var-testing
Browse files Browse the repository at this point in the history
tests: Strengthen check for /usr/share/factory/var logic
  • Loading branch information
cgwalters committed Feb 11, 2024
2 parents 29727e3 + 5281e67 commit 0ded4e8
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions lib/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use ostree_ext::container::{store, ManifestDiff};
use ostree_ext::container::{
Config, ExportOpts, ImageReference, OstreeImageReference, SignatureSource, Transport,
};
use ostree_ext::ocidir;
use ostree_ext::prelude::{Cast, FileExt};
use ostree_ext::tar::TarImportOptions;
use ostree_ext::{gio, glib};
use ostree_ext::{ocidir, ostree_manual};
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::io::{BufReader, BufWriter};
Expand Down Expand Up @@ -912,14 +912,15 @@ async fn test_container_var_content() -> Result<()> {
let srcpath = imgref.imgref.name.as_str();
oci_clone(srcpath, derived_path).await.unwrap();
let temproot = &fixture.path.join("temproot");
let junk_var_data = "junk var data";
|| -> Result<_> {
std::fs::create_dir(temproot)?;
let temprootd = Dir::open_ambient_dir(temproot, cap_std::ambient_authority())?;
let mut db = DirBuilder::new();
db.mode(0o755);
db.recursive(true);
temprootd.create_dir_with("var/lib", &db)?;
temprootd.write("var/lib/foo", "junk var data")?;
temprootd.write("var/lib/foo", junk_var_data)?;
Ok(())
}()
.context("generating temp content")?;
Expand All @@ -938,7 +939,23 @@ async fn test_container_var_content() -> Result<()> {
store::PrepareResult::AlreadyPresent(_) => panic!("should not be already imported"),
store::PrepareResult::Ready(r) => r,
};
let _import = imp.import(prep).await.unwrap();
let import = imp.import(prep).await.unwrap();

let ostree_root = fixture
.destrepo()
.read_commit(&import.merge_commit, gio::Cancellable::NONE)?
.0;
let varfile = ostree_root
.child("usr/share/factory/var/lib/foo")
.downcast::<ostree::RepoFile>()
.unwrap();
assert_eq!(
ostree_manual::repo_file_read_to_string(&varfile)?,
junk_var_data
);
assert!(!ostree_root
.child("var/lib/foo")
.query_exists(gio::Cancellable::NONE));

assert!(
store::image_filtered_content_warning(fixture.destrepo(), &derived_imgref.imgref)
Expand Down

0 comments on commit 0ded4e8

Please sign in to comment.