From 2878a5431b072f36b1d03bd7ee011f26db5dfc0e Mon Sep 17 00:00:00 2001 From: Jens Reimann Date: Tue, 1 Oct 2024 15:47:51 +0200 Subject: [PATCH] test: assert some details of the ingested OSV --- .../tests/advisory/osv/reingest.rs | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/modules/fundamental/tests/advisory/osv/reingest.rs b/modules/fundamental/tests/advisory/osv/reingest.rs index fcfed4f97..c99811493 100644 --- a/modules/fundamental/tests/advisory/osv/reingest.rs +++ b/modules/fundamental/tests/advisory/osv/reingest.rs @@ -1,7 +1,10 @@ use super::{twice, update_mark_fixed_again, update_unmark_fixed}; use test_context::test_context; use test_log::test; -use trustify_module_fundamental::vulnerability::service::VulnerabilityService; +use trustify_common::purl::Purl; +use trustify_module_fundamental::{ + purl::service::PurlService, vulnerability::service::VulnerabilityService, +}; use trustify_module_ingestor::common::Deprecation; use trustify_test_context::TrustifyContext; @@ -62,11 +65,37 @@ async fn withdrawn(ctx: &TrustifyContext) -> anyhow::Result<()> { assert_eq!(v.advisories.len(), 2); - println!("{v:#?}"); - assert_eq!(v.advisories[0].head.head.identifier, "RSEC-2023-6"); assert_eq!(v.advisories[1].head.head.identifier, "RSEC-2023-6"); + // check status + + let service = PurlService::new(ctx.db.clone()); + let purls = service + .base_purls(Default::default(), Default::default(), ()) + .await?; + + println!("PURLs: {purls:#?}"); + + let purl = purls + .items + .iter() + .find(|purl| purl.head.purl.name == "commonmark") + .expect("must find one"); + + assert_eq!( + purl.head.purl, + Purl { + ty: "cran".to_string(), + namespace: None, + name: "commonmark".to_string(), + version: None, + qualifiers: Default::default(), + } + ); + + // TODO: check status via purl version ranges + // done Ok(())