1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! API Client fixtures for E2E testing
//!
//! Provides helper functions for creating APIClient instances
//! that connect to test servers.
//!
//! ## Overview
//!
//! This module provides helper functions for creating `APIClient` instances
//! configured to connect to test servers. Use `api_client_from_url` with
//! the server URL obtained from `TestServerGuard`.
//!
//! ## Usage Examples
//!
//! ### Using api_client_from_url with TestServerGuard
//!
//! ```rust,no_run
//! use reinhardt_testkit::fixtures::{test_server_guard, api_client_from_url, TestServerGuard};
//! use reinhardt_urls::routers::UnifiedRouter;
//! use rstest::*;
//!
//! #[rstest]
//! #[tokio::test]
//! async fn test_api() {
//! let router = UnifiedRouter::new();
//! let server = test_server_guard(router).await;
//! let client = api_client_from_url(&server.url);
//! let response = client.get("/api/test").await.unwrap();
//! assert_eq!(response.status_code(), 200);
//! }
//! ```
//!
//! ### Creating APIClient directly
//!
//! ```rust,no_run
//! use reinhardt_testkit::APIClient;
//!
//! # async fn example() {
//! let client = APIClient::with_base_url("http://localhost:8080");
//! let response = client.get("/api/test").await.unwrap();
//! # }
//! ```
use crateAPIClient;
/// Create an APIClient from a server URL string
///
/// This is a helper function for creating an `APIClient` when you already
/// have a server URL. Use this when you need more control over the server
/// setup or when working with existing test infrastructure.
///
/// # Arguments
///
/// * `url` - The base URL of the server to connect to (e.g., "http://localhost:8080")
///
/// # Examples
///
/// ```rust,no_run
/// use reinhardt_testkit::fixtures::api_client_from_url;
///
/// # async fn example() {
/// let client = api_client_from_url("http://localhost:8080");
/// let response = client.get("/api/users").await.unwrap();
/// # }
/// ```
///
/// # Usage with TestServerGuard
///
/// ```rust,no_run
/// use reinhardt_testkit::fixtures::{test_server_guard, api_client_from_url, TestServerGuard};
/// use rstest::*;
///
/// #[rstest]
/// #[tokio::test]
/// async fn test_with_custom_setup(#[future] test_server_guard: TestServerGuard) {
/// let server = test_server_guard.await;
/// let client = api_client_from_url(&server.url);
/// let response = client.get("/test").await.unwrap();
/// }
/// ```