Skip to content

Commit

Permalink
Add a few tests affirming the V1 parity sort/query fields
Browse files Browse the repository at this point in the history
Relates to trustification#886

Signed-off-by: Jim Crossley <[email protected]>
  • Loading branch information
jcrossley3 committed Nov 4, 2024
1 parent 4b5a15d commit 030790f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
21 changes: 21 additions & 0 deletions common/src/db/query/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,25 @@ mod tests {

Ok(())
}

#[test(tokio::test)]
async fn table_aliasing() -> Result<(), anyhow::Error> {
let clause = advisory::Entity::find()
.select_only()
.column(advisory::Column::Id)
.filtering_with(
q("location=here"),
advisory::Entity.columns().alias("advisory", "foo"),
)?
.build(sea_orm::DatabaseBackend::Postgres)
.to_string()
.split("WHERE ")
.last()
.unwrap()
.to_string();

assert_eq!(clause, r#""foo"."location" = 'here'"#);

Ok(())
}
}
7 changes: 6 additions & 1 deletion modules/fundamental/src/sbom/service/sbom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,12 @@ mod test {
let fetch = SbomService::new(ctx.db.clone());

let fetched = fetch
.fetch_sboms(q("MySpAcE").sort("name"), Paginated::default(), (), ())
.fetch_sboms(
q("MySpAcE").sort("name,authors,published"),
Paginated::default(),
(),
(),
)
.await?;

log::debug!("{:#?}", fetched.items);
Expand Down

0 comments on commit 030790f

Please sign in to comment.