Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

tests: Two more fixture porting patches #265

Merged
merged 2 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions lib/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,15 @@ impl Fixture {
.transaction_set_ref(None, self.testref(), Some(commit.as_str()));
tx.commit(cancellable)?;

let detached = glib::VariantDict::new(None);
detached.insert("my-detached-key", &"my-detached-value");
let detached = detached.to_variant();
self.srcrepo.write_commit_detached_metadata(
commit.as_str(),
Some(&detached),
gio::NONE_CANCELLABLE,
)?;

let gpghome = self.path.join("src/gpghome");
self.srcrepo.sign_commit(
&commit,
Expand Down
14 changes: 6 additions & 8 deletions lib/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use std::process::Command;
use ostree_ext::fixture::{FileDef, Fixture, CONTENTS_CHECKSUM_V0};

const EXAMPLE_TAR_LAYER: &[u8] = include_bytes!("fixtures/hlinks.tar.gz");
const EXAMPLEOS_CONTENT_CHECKSUM: &str =
"0ef7461f9db15e1d8bd8921abf20694225fbaa4462cadf7deed8ea0e43162120";
const TEST_REGISTRY_DEFAULT: &str = "localhost:5000";

fn assert_err_contains<T>(r: Result<T>, s: impl AsRef<str>) {
Expand Down Expand Up @@ -203,7 +201,7 @@ fn validate_tar_expected<T: std::io::Read>(
fn test_tar_export_structure() -> Result<()> {
use tar::EntryType::{Directory, Regular};

let mut fixture = Fixture::new()?;
let mut fixture = Fixture::new_v1()?;
let src_tar = fixture.export_tar()?;
let src_tar = std::io::BufReader::new(fixture.dir.open(src_tar)?);
let mut src_tar = tar::Archive::new(src_tar);
Expand Down Expand Up @@ -235,7 +233,7 @@ fn test_tar_export_structure() -> Result<()> {
("sysroot/ostree/repo/tmp", Directory, 0o755),
("sysroot/ostree/repo/tmp/cache", Directory, 0o755),
("sysroot/ostree/repo/xattrs", Directory, 0o755),
("sysroot/ostree/repo/xattrs/44299b6a1738aab86de5966507fbe369af2ab421e1c6eb6e797054831430d92c", Regular, 0o644),
("sysroot/ostree/repo/xattrs/d67db507c5a6e7bfd078f0f3ded0a5669479a902e812931fc65c6f5e01831ef5", Regular, 0o644),
("usr", Directory, 0o755),
];
validate_tar_expected(
Expand Down Expand Up @@ -279,15 +277,15 @@ fn test_tar_export_structure() -> Result<()> {

#[tokio::test]
async fn test_tar_import_export() -> Result<()> {
let fixture = Fixture::new()?;
let fixture = Fixture::new_v1()?;
let p = fixture.export_tar()?;
let src_tar = tokio::fs::File::from_std(fixture.dir.open(p)?.into_std());

let imported_commit: String =
ostree_ext::tar::import_tar(fixture.destrepo(), src_tar, None).await?;
let (commitdata, _) = fixture.destrepo().load_commit(&imported_commit)?;
assert_eq!(
EXAMPLEOS_CONTENT_CHECKSUM,
CONTENTS_CHECKSUM_V0,
ostree::commit_get_content_checksum(&commitdata)
.unwrap()
.as_str()
Expand Down Expand Up @@ -317,7 +315,7 @@ async fn test_tar_import_export() -> Result<()> {

#[tokio::test]
async fn test_tar_write() -> Result<()> {
let fixture = Fixture::new()?;
let fixture = Fixture::new_v1()?;
// Test translating /etc to /usr/etc
fixture.dir.create_dir_all("tmproot/etc")?;
let tmproot = &fixture.dir.open_dir("tmproot")?;
Expand Down Expand Up @@ -348,7 +346,7 @@ async fn test_tar_write() -> Result<()> {

#[tokio::test]
async fn test_tar_write_tar_layer() -> Result<()> {
let fixture = Fixture::new()?;
let fixture = Fixture::new_v1()?;
let uncompressed_tar = tokio::io::BufReader::new(
async_compression::tokio::bufread::GzipDecoder::new(EXAMPLE_TAR_LAYER),
);
Expand Down