fastapi_output/testing/
fixtures.rs1#[derive(Debug, Clone)]
5pub struct FixtureRoute {
6 pub method: &'static str,
8 pub path: &'static str,
10 pub handler_name: Option<&'static str>,
12}
13
14#[must_use]
16pub fn sample_routes() -> Vec<FixtureRoute> {
17 vec![
18 FixtureRoute {
19 method: "GET",
20 path: "/users",
21 handler_name: Some("list_users"),
22 },
23 FixtureRoute {
24 method: "POST",
25 path: "/users",
26 handler_name: Some("create_user"),
27 },
28 FixtureRoute {
29 method: "GET",
30 path: "/users/{id}",
31 handler_name: Some("get_user"),
32 },
33 ]
34}
35
36#[derive(Debug, Clone)]
38pub struct FixtureValidationError {
39 pub path: Vec<&'static str>,
41 pub message: &'static str,
43 pub code: &'static str,
45 pub expected: Option<&'static str>,
47 pub received: Option<&'static str>,
49}
50
51#[must_use]
53pub fn sample_validation_errors() -> Vec<FixtureValidationError> {
54 vec![FixtureValidationError {
55 path: vec!["email"],
56 message: "Invalid email format",
57 code: "email",
58 expected: Some("valid email address"),
59 received: Some("not-an-email"),
60 }]
61}
62
63#[derive(Debug, Clone)]
65pub struct FixtureMiddlewareInfo {
66 pub name: &'static str,
68 pub type_name: &'static str,
70 pub order: usize,
72 pub can_short_circuit: bool,
74 pub config_summary: Option<&'static str>,
76}
77
78#[must_use]
80pub fn sample_middleware() -> Vec<FixtureMiddlewareInfo> {
81 vec![
82 FixtureMiddlewareInfo {
83 name: "RequestLogger",
84 type_name: "fastapi::middleware::RequestLogger",
85 order: 0,
86 can_short_circuit: false,
87 config_summary: Some("level=INFO"),
88 },
89 FixtureMiddlewareInfo {
90 name: "Auth",
91 type_name: "fastapi::middleware::Auth",
92 order: 1,
93 can_short_circuit: true,
94 config_summary: Some("scheme=Bearer"),
95 },
96 ]
97}