use modelmux::config::{Config, LogLevel, ServiceAccountKey, StreamingMode};
#[tokio::test]
async fn test_create_app_succeeds() {
let config = create_test_config();
let result = modelmux::create_app(config).await;
match result {
Ok(_) => {
}
Err(e) => {
assert!(
matches!(e, modelmux::ProxyError::Auth(_)),
"Should fail with Auth error (invalid credentials), not config error. Got: {:?}",
e
);
}
}
}
#[tokio::test]
async fn test_create_app_handles_invalid_config() {
let config = create_test_config();
let app = modelmux::create_app(config).await;
assert!(app.is_ok() || app.is_err(), "create_app should return Result");
}
fn create_test_config() -> Config {
use modelmux::provider::{AuthStrategy, LlmProviderConfig, VertexProvider};
let service_account_key = ServiceAccountKey {
account_type: "service_account".to_string(),
project_id: "test-project".to_string(),
private_key_id: "test-key-id".to_string(),
private_key: "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC\n-----END PRIVATE KEY-----\n".to_string(),
client_email: "test@test-project.iam.gserviceaccount.com".to_string(),
client_id: "123456789".to_string(),
auth_uri: "https://accounts.google.com/o/oauth2/auth".to_string(),
token_uri: "https://oauth2.googleapis.com/token".to_string(),
auth_provider_x509_cert_url: "https://www.googleapis.com/oauth2/v1/certs".to_string(),
client_x509_cert_url: "https://www.googleapis.com/robot/v1/metadata/x509/test%40test-project.iam.gserviceaccount.com".to_string(),
universe_domain: None,
};
let vertex = VertexProvider {
predict_resource_url: "https://test.example.com/v1/test-model".to_string(),
display_model: "test-model".to_string(),
auth: AuthStrategy::GcpOAuth2(service_account_key),
};
Config {
server: modelmux::config::ServerConfig {
port: 3000,
log_level: LogLevel::Info,
enable_retries: true,
max_retry_attempts: 3,
},
auth: modelmux::config::AuthConfig::default(),
streaming: modelmux::config::StreamingConfig {
mode: StreamingMode::Auto,
buffer_size: 65536,
chunk_timeout_ms: 5000,
},
vertex: None,
llm_provider: Some(LlmProviderConfig::Vertex(vertex)),
}
}