[router] Add builder pattern for RouterConfig with zero duplication (#12030)
This commit is contained in:
@@ -902,17 +902,10 @@ async fn test_openai_router_models_auth_forwarding() {
|
||||
|
||||
#[test]
|
||||
fn oracle_config_validation_requires_config_when_enabled() {
|
||||
let config = RouterConfig {
|
||||
chat_template: None,
|
||||
mode: RoutingMode::OpenAI {
|
||||
worker_urls: vec!["https://api.openai.com".to_string()],
|
||||
},
|
||||
history_backend: HistoryBackend::Oracle,
|
||||
oracle: None,
|
||||
reasoning_parser: None,
|
||||
tool_call_parser: None,
|
||||
..Default::default()
|
||||
};
|
||||
let config = RouterConfig::builder()
|
||||
.openai_mode(vec!["https://api.openai.com".to_string()])
|
||||
.history_backend(HistoryBackend::Oracle)
|
||||
.build_unchecked();
|
||||
|
||||
let err =
|
||||
ConfigValidator::validate(&config).expect_err("config should fail without oracle details");
|
||||
@@ -927,13 +920,9 @@ fn oracle_config_validation_requires_config_when_enabled() {
|
||||
|
||||
#[test]
|
||||
fn oracle_config_validation_accepts_dsn_only() {
|
||||
let config = RouterConfig {
|
||||
chat_template: None,
|
||||
mode: RoutingMode::OpenAI {
|
||||
worker_urls: vec!["https://api.openai.com".to_string()],
|
||||
},
|
||||
history_backend: HistoryBackend::Oracle,
|
||||
oracle: Some(OracleConfig {
|
||||
let config = RouterConfig::builder()
|
||||
.openai_mode(vec!["https://api.openai.com".to_string()])
|
||||
.oracle_history(OracleConfig {
|
||||
wallet_path: None,
|
||||
connect_descriptor: "tcps://db.example.com:1522/service".to_string(),
|
||||
username: "scott".to_string(),
|
||||
@@ -941,22 +930,17 @@ fn oracle_config_validation_accepts_dsn_only() {
|
||||
pool_min: 1,
|
||||
pool_max: 4,
|
||||
pool_timeout_secs: 30,
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
})
|
||||
.build_unchecked();
|
||||
|
||||
ConfigValidator::validate(&config).expect("dsn-based config should validate");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oracle_config_validation_accepts_wallet_alias() {
|
||||
let config = RouterConfig {
|
||||
chat_template: None,
|
||||
mode: RoutingMode::OpenAI {
|
||||
worker_urls: vec!["https://api.openai.com".to_string()],
|
||||
},
|
||||
history_backend: HistoryBackend::Oracle,
|
||||
oracle: Some(OracleConfig {
|
||||
let config = RouterConfig::builder()
|
||||
.openai_mode(vec!["https://api.openai.com".to_string()])
|
||||
.oracle_history(OracleConfig {
|
||||
wallet_path: Some("/etc/sglang/oracle-wallet".to_string()),
|
||||
connect_descriptor: "db_low".to_string(),
|
||||
username: "app_user".to_string(),
|
||||
@@ -964,9 +948,8 @@ fn oracle_config_validation_accepts_wallet_alias() {
|
||||
pool_min: 1,
|
||||
pool_max: 8,
|
||||
pool_timeout_secs: 45,
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
})
|
||||
.build_unchecked();
|
||||
|
||||
ConfigValidator::validate(&config).expect("wallet-based config should validate");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user