Skip to content

Commit

Permalink
test: use existing ingest method
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Jul 11, 2024
1 parent d46a519 commit 89e0c21
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 26 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl MigrationTrait for Migration {
.not_null(),
)
.add_foreign_key(
&TableForeignKey::new()
TableForeignKey::new()
.name(FK_NAME)
.from_tbl(VulnerabilityDescription::Table)
.from_col(VulnerabilityDescription::AdvisoryId)
Expand Down
1 change: 0 additions & 1 deletion modules/ingestor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ uuid = { workspace = true, features = ["v7"] }
[dev-dependencies]
trustify-test-context = { workspace = true }

futures-util = { workspace = true }
rand = { workspace = true }
rstest = {workspace = true }
serde_yaml = { workspace = true }
Expand Down
25 changes: 2 additions & 23 deletions modules/ingestor/tests/cve.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
#![allow(clippy::expect_used)]

use anyhow::bail;
use futures_util::stream;
use std::convert::Infallible;
use test_context::test_context;
use test_log::test;
use trustify_common::id::Id;
use trustify_module_ingestor::service::{Format, IngestorService};
use trustify_test_context::TrustifyContext;

#[test_context(TrustifyContext)]
#[test(tokio::test)]
async fn reingest_cve(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
let ingestor = IngestorService::new(ctx.graph.clone(), ctx.storage.clone());

let data = ctx.document_bytes("cve/CVE-2021-32714.json").await?;

// ingest once

let result = ingestor
.ingest(
(),
None,
Format::CVE,
stream::iter([Ok::<_, Infallible>(data.clone())]),
)
.await?;
let result = ctx.ingest_document("cve/CVE-2021-32714.json").await?;

let Id::Uuid(id) = result.id else {
bail!("must be an id")
Expand All @@ -48,14 +34,7 @@ async fn reingest_cve(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {

// ingest second time

ingestor
.ingest(
(),
None,
Format::CVE,
stream::iter([Ok::<_, Infallible>(data)]),
)
.await?;
let result = ctx.ingest_document("cve/CVE-2021-32714.json").await?;

let Id::Uuid(id) = result.id else {
bail!("must be an id")
Expand Down

0 comments on commit 89e0c21

Please sign in to comment.