Skip to content

Commit

Permalink
Merge pull request #264 from cgwalters/test-fixture-ng5
Browse files Browse the repository at this point in the history
tests: Port two tests to v1 fixture
  • Loading branch information
jmarrero committed Mar 8, 2022
2 parents be4319f + db8f7ab commit 0b40795
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions lib/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ d run
m 0 0 1755
d tmp
"## };
pub const CONTENTS_CHECKSUM_V0: &str =
"76f0d5ec8814bc2a1d7868dbe8d3783535dc0cc9c7dcfdf37fa3512f8e276f6c";

#[derive(Debug, PartialEq, Eq)]
enum SeLabel {
Expand Down Expand Up @@ -394,6 +396,14 @@ impl Fixture {
.transaction_set_ref(None, self.testref(), Some(commit.as_str()));
tx.commit(cancellable)?;

let gpghome = self.path.join("src/gpghome");
self.srcrepo.sign_commit(
&commit,
TEST_GPG_KEYID_1,
Some(gpghome.as_str()),
gio::NONE_CANCELLABLE,
)?;

Ok(())
}

Expand Down
10 changes: 5 additions & 5 deletions lib/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::process::Command;

use ostree_ext::fixture::{FileDef, Fixture};
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 =
Expand All @@ -35,7 +35,7 @@ static TEST_REGISTRY: Lazy<String> = Lazy::new(|| match std::env::var_os("TEST_R

#[tokio::test]
async fn test_tar_import_empty() -> Result<()> {
let fixture = Fixture::new()?;
let fixture = Fixture::new_v1()?;
let r = ostree_ext::tar::import_tar(fixture.destrepo(), tokio::io::empty(), None).await;
assert_err_contains(r, "Commit object not found");
Ok(())
Expand Down Expand Up @@ -65,7 +65,7 @@ async fn test_tar_export_reproducible() -> Result<()> {

#[tokio::test]
async fn test_tar_import_signed() -> Result<()> {
let fixture = Fixture::new()?;
let fixture = Fixture::new_v1()?;
let test_tar = fixture.export_tar()?;

let rev = fixture.srcrepo().require_rev(fixture.testref())?;
Expand All @@ -74,7 +74,7 @@ async fn test_tar_import_signed() -> Result<()> {
ostree::commit_get_content_checksum(&commitv)
.unwrap()
.as_str(),
EXAMPLEOS_CONTENT_CHECKSUM
CONTENTS_CHECKSUM_V0
);

// Verify we fail with an unknown remote.
Expand Down Expand Up @@ -122,7 +122,7 @@ async fn test_tar_import_signed() -> Result<()> {
.await?;
let (commitdata, state) = fixture.destrepo().load_commit(&imported)?;
assert_eq!(
EXAMPLEOS_CONTENT_CHECKSUM,
CONTENTS_CHECKSUM_V0,
ostree::commit_get_content_checksum(&commitdata)
.unwrap()
.as_str()
Expand Down

0 comments on commit 0b40795

Please sign in to comment.