forked from trustification/trustify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for AI 'package-info' tool
Signed-off-by: mrizzi <[email protected]>
- Loading branch information
Showing
1 changed file
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ pub fn sanitize_uuid_urn(value: String) -> String { | |
|
||
#[test_context(TrustifyContext)] | ||
#[test(actix_web::test)] | ||
async fn completions(ctx: &TrustifyContext) -> Result<(), anyhow::Error> { | ||
async fn test_completions_sbom_info(ctx: &TrustifyContext) -> Result<(), anyhow::Error> { | ||
let service = AiService::new(ctx.db.clone()); | ||
if !service.completions_enabled() { | ||
return Ok(()); // skip test | ||
|
@@ -91,3 +91,32 @@ async fn completions(ctx: &TrustifyContext) -> Result<(), anyhow::Error> { | |
|
||
Ok(()) | ||
} | ||
|
||
#[test_context(TrustifyContext)] | ||
#[test(actix_web::test)] | ||
async fn test_completions_package_info(ctx: &TrustifyContext) -> Result<(), anyhow::Error> { | ||
let service = AiService::new(ctx.db.clone()); | ||
if !service.completions_enabled() { | ||
return Ok(()); // skip test | ||
} | ||
|
||
ingest_fixtures(ctx).await?; | ||
|
||
let mut req = ChatState::new(); | ||
req.add_human_message("List the httpclient packages with their identifiers".into()); | ||
|
||
let result = service.completions(&req, ()).await?; | ||
|
||
log::info!("result: {:#?}", result); | ||
let last_message_content = result.messages.last().unwrap().content.clone(); | ||
println!( | ||
"Test formatted output:\n\n{}\n", | ||
termimad::inline(last_message_content.as_str()) | ||
); | ||
assert!(last_message_content.contains("/[email protected]")); | ||
assert!(last_message_content | ||
.contains("/[email protected]")); | ||
assert!(last_message_content.contains("/[email protected]")); | ||
|
||
Ok(()) | ||
} |