#![allow(dead_code)]
#![allow(unused_imports)]
pub mod fixtures;
use serde_json::json;
use wiremock::matchers::{basic_auth, header, method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};
pub async fn setup_mock_server() -> MockServer {
MockServer::start().await
}
pub fn success_response(body: serde_json::Value) -> ResponseTemplate {
ResponseTemplate::new(200).set_body_json(body)
}
pub fn error_response(code: u16, message: &str) -> ResponseTemplate {
ResponseTemplate::new(code).set_body_json(json!({
"error": message,
"code": code
}))
}
pub fn no_content_response() -> ResponseTemplate {
ResponseTemplate::new(204)
}
pub fn created_response(body: serde_json::Value) -> ResponseTemplate {
ResponseTemplate::new(201).set_body_json(body)
}
pub fn enterprise_auth(username: &str, password: &str) -> impl wiremock::Match {
basic_auth(username, password)
}
pub fn cloud_auth() -> Vec<Box<dyn wiremock::Match>> {
vec![
Box::new(header("x-api-key", "test-key")),
Box::new(header("x-api-secret-key", "test-secret")),
]
}
pub fn test_database() -> serde_json::Value {
json!({
"uid": 1,
"name": "test-db",
"type": "redis",
"memory_size": 1073741824,
"port": 12000,
"status": "active"
})
}
pub fn test_cluster() -> serde_json::Value {
json!({
"name": "test-cluster",
"nodes": [1, 2, 3],
"databases": [1, 2],
"version": "7.2.0",
"license_expired": false
})
}
pub fn test_node() -> serde_json::Value {
json!({
"uid": 1,
"address": "192.168.1.10",
"status": "active",
"role": "master",
"total_memory": 16000000000i64,
"used_memory": 8000000000i64
})
}
pub fn test_user() -> serde_json::Value {
json!({
"uid": 1,
"username": "testuser",
"email": "test@example.com",
"role": "admin",
"status": "active"
})
}
pub fn action_response(action: &str) -> serde_json::Value {
json!({
"action_uid": format!("{}-123", action),
"status": "completed",
"progress": 100
})
}
pub fn task_response(task_id: &str) -> serde_json::Value {
json!({
"task_id": task_id,
"status": "completed",
"progress": 100,
"description": "Task completed successfully"
})
}