Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Strengthen check for /usr/share/factory/var logic #600

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading