mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -198,14 +198,13 @@ pub fn get_csrf_token(request: &Request) -> String {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::config::{AdminConfig, ProxyConfig, RuntimeEnv};
|
||||
use crate::config::{AdminConfig, ProxyConfig};
|
||||
use crate::state::AppState;
|
||||
use axum::{Router, middleware::from_fn_with_state, routing::get};
|
||||
use tower::ServiceExt;
|
||||
|
||||
fn state_with_admin_endpoint(admin_endpoint: &str) -> AppState {
|
||||
AppState::new(AdminConfig {
|
||||
env: RuntimeEnv::Production,
|
||||
host: String::new(),
|
||||
port: 3020,
|
||||
secret_key_base: "test-secret".to_owned(),
|
||||
|
||||
@@ -108,66 +108,3 @@ pub fn set_flash_cookie(response: &mut Response, flash: &FlashData, secure: bool
|
||||
response.headers_mut().append(header::SET_COOKIE, v);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn serialize_then_parse_round_trips() {
|
||||
let flash = FlashData::success("Item saved");
|
||||
let encoded = serialize_flash(&flash);
|
||||
let decoded = parse_flash(&encoded).expect("must parse");
|
||||
assert_eq!(decoded.message, "Item saved");
|
||||
assert_eq!(decoded.flash_type, "success");
|
||||
assert!(decoded.detail.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_flash_returns_none_for_invalid_base64() {
|
||||
assert!(parse_flash("!!!not-base64!!!").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_flash_returns_none_for_invalid_json() {
|
||||
let encoded = base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(b"not json");
|
||||
assert!(parse_flash(&encoded).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flash_success_sets_correct_type() {
|
||||
let f = FlashData::success("ok");
|
||||
assert_eq!(f.flash_type, "success");
|
||||
assert_eq!(f.message, "ok");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flash_error_sets_correct_type() {
|
||||
let f = FlashData::error("fail");
|
||||
assert_eq!(f.flash_type, "error");
|
||||
assert_eq!(f.message, "fail");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flash_info_sets_correct_type() {
|
||||
let f = FlashData::info("note");
|
||||
assert_eq!(f.flash_type, "info");
|
||||
assert_eq!(f.message, "note");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_flash_message_maps_levels() {
|
||||
assert!(matches!(
|
||||
FlashData::success("").to_flash_message().level,
|
||||
FlashLevel::Success
|
||||
));
|
||||
assert!(matches!(
|
||||
FlashData::error("").to_flash_message().level,
|
||||
FlashLevel::Error
|
||||
));
|
||||
assert!(matches!(
|
||||
FlashData::info("").to_flash_message().level,
|
||||
FlashLevel::Info
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user