Skip to content

Commit

Permalink
Extract warning message as constant
Browse files Browse the repository at this point in the history
Signed-off-by: Mateus Devino <mateus@mdevino.com>
  • Loading branch information
mdevino committed Mar 3, 2025
1 parent b27a6e0 commit 640d35b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/common/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub const ORCHESTRATOR_CONTENT_DETECTION_ENDPOINT: &str = "/api/v2/text/detectio
// Messages
pub const ORCHESTRATOR_INTERNAL_SERVER_ERROR_MESSAGE: &str =
"unexpected error occurred while processing request";
pub const ORCHESTRATOR_UNSUITABLE_INPUT_MESSAGE: &str = "Unsuitable input detected. Please check the detected entities on your input and try again with the unsuitable input removed.";

pub fn ensure_global_rustls_state() {
let _ = ring::default_provider().install_default();
Expand Down
9 changes: 8 additions & 1 deletion tests/streaming_classification_with_gen_nlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use common::{
orchestrator::{
SseStream, TestOrchestratorServer, ORCHESTRATOR_CONFIG_FILE_PATH,
ORCHESTRATOR_INTERNAL_SERVER_ERROR_MESSAGE, ORCHESTRATOR_STREAMING_ENDPOINT,
ORCHESTRATOR_UNSUITABLE_INPUT_MESSAGE,
},
};
use fms_guardrails_orchestr8::{
Expand Down Expand Up @@ -538,7 +539,13 @@ async fn test_input_detector_whole_doc_with_detections() -> Result<(), anyhow::E
}
);
assert!(messages[0].input_token_count == mock_tokenization_response.token_count as u32);
assert!(messages[0].warnings == Some(vec![DetectionWarning{ id: Some(fms_guardrails_orchestr8::models::DetectionWarningReason::UnsuitableInput), message: Some("Unsuitable input detected. Please check the detected entities on your input and try again with the unsuitable input removed.".into()) }]));
assert!(
messages[0].warnings
== Some(vec![DetectionWarning {
id: Some(fms_guardrails_orchestr8::models::DetectionWarningReason::UnsuitableInput),
message: Some(ORCHESTRATOR_UNSUITABLE_INPUT_MESSAGE.into())
}])
);

Ok(())
}
Expand Down

0 comments on commit 640d35b

Please sign in to comment.