huskies: merge 950
This commit is contained in:
@@ -7,7 +7,6 @@ use crate::services::Services;
|
||||
use crate::state::SessionState;
|
||||
use crate::store::JsonFileStore;
|
||||
use crate::workflow::WorkflowState;
|
||||
use poem::http::StatusCode;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{broadcast, mpsc, oneshot};
|
||||
|
||||
@@ -121,35 +120,10 @@ impl AppContext {
|
||||
}
|
||||
}
|
||||
|
||||
/// Alias for `poem::Result<T>` used by OpenAPI handler return types.
|
||||
pub type OpenApiResult<T> = poem::Result<T>;
|
||||
|
||||
/// Return a 400 Bad Request error with the given message.
|
||||
pub fn bad_request(message: String) -> poem::Error {
|
||||
poem::Error::from_string(message, StatusCode::BAD_REQUEST)
|
||||
}
|
||||
|
||||
/// Return a 404 Not Found error with the given message.
|
||||
pub fn not_found(message: String) -> poem::Error {
|
||||
poem::Error::from_string(message, StatusCode::NOT_FOUND)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn bad_request_returns_400_status() {
|
||||
let err = bad_request("something went wrong".to_string());
|
||||
assert_eq!(err.status(), StatusCode::BAD_REQUEST);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_request_accepts_empty_message() {
|
||||
let err = bad_request(String::new());
|
||||
assert_eq!(err.status(), StatusCode::BAD_REQUEST);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn permission_decision_equality() {
|
||||
assert_eq!(PermissionDecision::Deny, PermissionDecision::Deny);
|
||||
@@ -161,10 +135,4 @@ mod tests {
|
||||
assert_ne!(PermissionDecision::Deny, PermissionDecision::Approve);
|
||||
assert_ne!(PermissionDecision::Approve, PermissionDecision::AlwaysAllow);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn not_found_returns_404_status() {
|
||||
let err = not_found("item not found".to_string());
|
||||
assert_eq!(err.status(), StatusCode::NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user