Skip to content

Commit 1af2d7b

Browse files
mrrajanclaude
andcommitted
fix: adapt tests and imports for release/0.4.z
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 9ce01a3 commit 1af2d7b

File tree

4 files changed

+34
-26
lines changed

4 files changed

+34
-26
lines changed

modules/fundamental/src/license/service/test.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use test_log::test;
55
use trustify_common::{db::query::Query, id::Id, model::Paginated};
66
use trustify_entity::{expanded_license, sbom_license_expanded};
77
use trustify_test_context::TrustifyContext;
8-
use uuid::Uuid;
98

109
/// RED-GREEN-REFACTOR: Test licenses() UNION query
1110
/// Verifies: expanded_license.expanded_text UNION license.text for CycloneDX
@@ -74,7 +73,10 @@ async fn test_get_all_license_info_coalesce(ctx: &TrustifyContext) -> Result<(),
7473
let result = ctx
7574
.ingest_document("spdx/OCP-TOOLS-4.11-RHEL-8.json")
7675
.await?;
77-
let sbom_id = Uuid::parse_str(&result.id)?;
76+
let sbom_id = result
77+
.id
78+
.try_as_uid()
79+
.ok_or_else(|| anyhow::anyhow!("Expected UUID ID"))?;
7880

7981
// GREEN: Get license info
8082
let info = service
@@ -119,7 +121,10 @@ async fn test_junction_table_mapping_integrity(ctx: &TrustifyContext) -> Result<
119121
let result = ctx
120122
.ingest_document("spdx/OCP-TOOLS-4.11-RHEL-8.json")
121123
.await?;
122-
let sbom_id = Uuid::parse_str(&result.id)?;
124+
let sbom_id = result
125+
.id
126+
.try_as_uid()
127+
.ok_or_else(|| anyhow::anyhow!("Expected UUID ID"))?;
123128

124129
// REFACTOR: Verify every junction entry references valid expanded_license
125130
let entries = sbom_license_expanded::Entity::find()
@@ -227,7 +232,10 @@ async fn test_coalesce_refactoring_correctness(ctx: &TrustifyContext) -> Result<
227232
let spdx_result = ctx
228233
.ingest_document("spdx/OCP-TOOLS-4.11-RHEL-8.json")
229234
.await?;
230-
let sbom_id = Uuid::parse_str(&spdx_result.id)?;
235+
let sbom_id = spdx_result
236+
.id
237+
.try_as_uid()
238+
.ok_or_else(|| anyhow::anyhow!("Expected UUID ID"))?;
231239

232240
let info = service
233241
.get_all_license_info(Id::Uuid(sbom_id), &ctx.db)

modules/fundamental/src/purl/model/details/purl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use crate::{
22
Error,
33
advisory::model::AdvisoryHead,
4-
common::{LicenseInfo, LicenseRefMapping, license_filtering},
4+
common::{LicenseInfo, LicenseRefMapping},
55
purl::model::{BasePurlHead, PurlHead, VersionedPurlHead},
66
sbom::{model::SbomHead, service::sbom::LicenseBasicInfo},
77
vulnerability::model::VulnerabilityHead,
88
};
99
use sea_orm::{
10-
ColumnTrait, ConnectionTrait, DbErr, EntityTrait, FromQueryResult, IntoSimpleExpr, LoaderTrait,
11-
ModelTrait, QueryFilter, QueryOrder, QueryResult, QuerySelect, QueryTrait, RelationTrait,
12-
Select, SelectColumns,
10+
ColumnTrait, ConnectionTrait, DbErr, EntityTrait, FromQueryResult, IntoSimpleExpr, Iterable,
11+
LoaderTrait, ModelTrait, QueryFilter, QueryOrder, QueryResult, QuerySelect, QueryTrait,
12+
RelationTrait, Select, SelectColumns,
1313
};
1414
use sea_query::{Asterisk, ColumnRef, Expr, Func, IntoIden, JoinType, SimpleExpr};
1515
use serde::{Deserialize, Serialize};

modules/fundamental/src/sbom/service/test.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,14 @@ async fn test_sbom_package_licenses_coalesce(ctx: &TrustifyContext) -> Result<()
673673
.ingest_document("zookeeper-3.9.2-cyclonedx.json")
674674
.await?;
675675

676-
let spdx_id = Uuid::parse_str(&spdx_result.id)?;
677-
let cyclonedx_id = Uuid::parse_str(&cyclonedx_result.id)?;
676+
let spdx_id = spdx_result
677+
.id
678+
.try_as_uid()
679+
.ok_or_else(|| anyhow::anyhow!("Expected UUID ID"))?;
680+
let cyclonedx_id = cyclonedx_result
681+
.id
682+
.try_as_uid()
683+
.ok_or_else(|| anyhow::anyhow!("Expected UUID ID"))?;
678684

679685
let spdx_packages = service
680686
.fetch_sbom_packages(
@@ -748,7 +754,10 @@ async fn test_sbom_package_license_filtering_with_coalesce(
748754
let result = ctx
749755
.ingest_document("spdx/OCP-TOOLS-4.11-RHEL-8.json")
750756
.await?;
751-
let sbom_id = Uuid::parse_str(&result.id)?;
757+
let sbom_id = result
758+
.id
759+
.try_as_uid()
760+
.ok_or_else(|| anyhow::anyhow!("Expected UUID ID"))?;
752761

753762
// Filter by license (should work via COALESCE on expanded_text OR text)
754763
let apache_packages = service
@@ -795,7 +804,10 @@ async fn test_sbom_package_license_not_null_filter(
795804
let result = ctx
796805
.ingest_document("spdx/OCP-TOOLS-4.11-RHEL-8.json")
797806
.await?;
798-
let sbom_id = Uuid::parse_str(&result.id)?;
807+
let sbom_id = result
808+
.id
809+
.try_as_uid()
810+
.ok_or_else(|| anyhow::anyhow!("Expected UUID ID"))?;
799811

800812
let packages = service
801813
.fetch_sbom_packages(

openapi.yaml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4347,13 +4347,7 @@ components:
43474347
type: array
43484348
items:
43494349
$ref: '#/components/schemas/LicenseRefMapping'
4350-
description: |-
4351-
LicenseRef mappings
4352-
4353-
**Deprecated**: Licenses are now pre-expanded at ingestion time via `expanded_license` /
4354-
`sbom_license_expanded` tables. This field is always empty and will be removed in a future
4355-
release.
4356-
deprecated: true
4350+
description: LicenseRef mappings
43574351
name:
43584352
type: string
43594353
description: The name of the package in the SBOM
@@ -4963,13 +4957,7 @@ components:
49634957
type: array
49644958
items:
49654959
$ref: '#/components/schemas/LicenseRefMapping'
4966-
description: |-
4967-
LicenseRef mappings
4968-
4969-
**Deprecated**: Licenses are now pre-expanded at ingestion time via `expanded_license` /
4970-
`sbom_license_expanded` tables. This field is always empty and will be removed in a future
4971-
release.
4972-
deprecated: true
4960+
description: LicenseRef mappings
49734961
name:
49744962
type: string
49754963
description: The name of the package in the SBOM

0 commit comments

Comments
 (0)