mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 18:59:50 +08:00
test(gateway): drop shared openai-scoped mappings in non-openai fixture cases
候选调度测试的共享夹具(support::sample_row)默认把上游名映射限定在 openai 格式;required_capability/selection 中走 gemini、claude 端点的 用例此前依赖“默认名兜底”的旧语义。新增 sample_row_without_model_mappings() 并替换 10 处调用,使这些用例继续只验证各自的 OAuth/能力过滤意图。
This commit is contained in:
@@ -19,7 +19,9 @@ use super::super::{
|
|||||||
list_selectable_candidates_for_required_capability_without_requested_model,
|
list_selectable_candidates_for_required_capability_without_requested_model,
|
||||||
list_selectable_candidates_for_required_capability_without_requested_model_with_auth_limit_signal,
|
list_selectable_candidates_for_required_capability_without_requested_model_with_auth_limit_signal,
|
||||||
};
|
};
|
||||||
use super::support::{sample_auth_snapshot, sample_provider, sample_row};
|
use super::support::{
|
||||||
|
sample_auth_snapshot, sample_provider, sample_row, sample_row_without_model_mappings,
|
||||||
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn compatible_required_capability_prefers_matching_keys_without_hard_filtering() {
|
async fn compatible_required_capability_prefers_matching_keys_without_hard_filtering() {
|
||||||
@@ -77,7 +79,7 @@ async fn compatible_required_capability_prefers_matching_keys_without_hard_filte
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn exclusive_required_capability_keeps_hard_filtering_only_matching_keys() {
|
async fn exclusive_required_capability_keeps_hard_filtering_only_matching_keys() {
|
||||||
let mut incompatible = sample_row();
|
let mut incompatible = sample_row_without_model_mappings();
|
||||||
incompatible.provider_id = "provider-a".to_string();
|
incompatible.provider_id = "provider-a".to_string();
|
||||||
incompatible.provider_name = "provider-a".to_string();
|
incompatible.provider_name = "provider-a".to_string();
|
||||||
incompatible.endpoint_id = "endpoint-a".to_string();
|
incompatible.endpoint_id = "endpoint-a".to_string();
|
||||||
@@ -89,7 +91,7 @@ async fn exclusive_required_capability_keeps_hard_filtering_only_matching_keys()
|
|||||||
incompatible.global_model_name = "gemini-2.5-pro".to_string();
|
incompatible.global_model_name = "gemini-2.5-pro".to_string();
|
||||||
incompatible.key_capabilities = Some(serde_json::json!({}));
|
incompatible.key_capabilities = Some(serde_json::json!({}));
|
||||||
|
|
||||||
let mut compatible = sample_row();
|
let mut compatible = sample_row_without_model_mappings();
|
||||||
compatible.provider_id = "provider-b".to_string();
|
compatible.provider_id = "provider-b".to_string();
|
||||||
compatible.provider_name = "provider-b".to_string();
|
compatible.provider_name = "provider-b".to_string();
|
||||||
compatible.endpoint_id = "endpoint-b".to_string();
|
compatible.endpoint_id = "endpoint-b".to_string();
|
||||||
@@ -133,7 +135,7 @@ async fn exclusive_required_capability_keeps_hard_filtering_only_matching_keys()
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn required_capability_without_model_uses_session_scoped_affinity() {
|
async fn required_capability_without_model_uses_session_scoped_affinity() {
|
||||||
let mut fallback = sample_row();
|
let mut fallback = sample_row_without_model_mappings();
|
||||||
fallback.provider_id = "provider-a".to_string();
|
fallback.provider_id = "provider-a".to_string();
|
||||||
fallback.provider_name = "provider-a".to_string();
|
fallback.provider_name = "provider-a".to_string();
|
||||||
fallback.endpoint_id = "endpoint-a".to_string();
|
fallback.endpoint_id = "endpoint-a".to_string();
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ use super::super::selection::{
|
|||||||
collect_selectable_candidates_with_skip_reasons as collect_selectable_candidates_with_skip_reasons_impl,
|
collect_selectable_candidates_with_skip_reasons as collect_selectable_candidates_with_skip_reasons_impl,
|
||||||
is_exact_all_skipped_by_auth_limit, select_minimal_candidate as select_candidate_impl,
|
is_exact_all_skipped_by_auth_limit, select_minimal_candidate as select_candidate_impl,
|
||||||
};
|
};
|
||||||
use super::support::{sample_auth_snapshot, sample_key, sample_provider, sample_row};
|
use super::support::{
|
||||||
|
sample_auth_snapshot, sample_key, sample_provider, sample_row,
|
||||||
|
sample_row_without_model_mappings,
|
||||||
|
};
|
||||||
|
|
||||||
async fn state_with_routing_default_policy(
|
async fn state_with_routing_default_policy(
|
||||||
data_state: GatewayDataState,
|
data_state: GatewayDataState,
|
||||||
@@ -2225,7 +2228,7 @@ async fn keeps_codex_candidate_selectable_when_oauth_token_is_expired() {
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn keeps_refreshable_kiro_candidate_selectable_with_runtime_oauth_invalid_marker() {
|
async fn keeps_refreshable_kiro_candidate_selectable_with_runtime_oauth_invalid_marker() {
|
||||||
let mut row = sample_row();
|
let mut row = sample_row_without_model_mappings();
|
||||||
row.provider_id = "provider-kiro".to_string();
|
row.provider_id = "provider-kiro".to_string();
|
||||||
row.provider_name = "kiro".to_string();
|
row.provider_name = "kiro".to_string();
|
||||||
row.provider_type = "kiro".to_string();
|
row.provider_type = "kiro".to_string();
|
||||||
@@ -2286,7 +2289,7 @@ async fn keeps_refreshable_kiro_candidate_selectable_with_runtime_oauth_invalid_
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn keeps_refreshable_kiro_candidate_selectable_when_oauth_token_expired() {
|
async fn keeps_refreshable_kiro_candidate_selectable_when_oauth_token_expired() {
|
||||||
let mut row = sample_row();
|
let mut row = sample_row_without_model_mappings();
|
||||||
row.provider_id = "provider-kiro".to_string();
|
row.provider_id = "provider-kiro".to_string();
|
||||||
row.provider_name = "kiro".to_string();
|
row.provider_name = "kiro".to_string();
|
||||||
row.provider_type = "kiro".to_string();
|
row.provider_type = "kiro".to_string();
|
||||||
@@ -2346,7 +2349,7 @@ async fn keeps_refreshable_kiro_candidate_selectable_when_oauth_token_expired()
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn keeps_kiro_candidate_selectable_after_refresh_token_failure_until_access_token_expiry() {
|
async fn keeps_kiro_candidate_selectable_after_refresh_token_failure_until_access_token_expiry() {
|
||||||
let mut row = sample_row();
|
let mut row = sample_row_without_model_mappings();
|
||||||
row.provider_id = "provider-kiro".to_string();
|
row.provider_id = "provider-kiro".to_string();
|
||||||
row.provider_name = "kiro".to_string();
|
row.provider_name = "kiro".to_string();
|
||||||
row.provider_type = "kiro".to_string();
|
row.provider_type = "kiro".to_string();
|
||||||
@@ -2411,7 +2414,7 @@ async fn keeps_kiro_candidate_selectable_after_refresh_token_failure_until_acces
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn skips_kiro_candidate_after_refresh_token_failure_and_access_token_expiry() {
|
async fn skips_kiro_candidate_after_refresh_token_failure_and_access_token_expiry() {
|
||||||
let mut row = sample_row();
|
let mut row = sample_row_without_model_mappings();
|
||||||
row.provider_id = "provider-kiro".to_string();
|
row.provider_id = "provider-kiro".to_string();
|
||||||
row.provider_name = "kiro".to_string();
|
row.provider_name = "kiro".to_string();
|
||||||
row.provider_type = "kiro".to_string();
|
row.provider_type = "kiro".to_string();
|
||||||
@@ -2477,7 +2480,7 @@ async fn skips_kiro_candidate_after_refresh_token_failure_and_access_token_expir
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn skips_refreshable_kiro_candidate_when_oauth_marker_is_account_block() {
|
async fn skips_refreshable_kiro_candidate_when_oauth_marker_is_account_block() {
|
||||||
let mut row = sample_row();
|
let mut row = sample_row_without_model_mappings();
|
||||||
row.provider_id = "provider-kiro".to_string();
|
row.provider_id = "provider-kiro".to_string();
|
||||||
row.provider_name = "kiro".to_string();
|
row.provider_name = "kiro".to_string();
|
||||||
row.provider_type = "kiro".to_string();
|
row.provider_type = "kiro".to_string();
|
||||||
@@ -2620,7 +2623,7 @@ async fn keeps_codex_candidate_selectable_when_exhausted_account_flag_is_disable
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn skips_kiro_candidate_when_account_quota_is_exhausted_and_pool_flag_enabled() {
|
async fn skips_kiro_candidate_when_account_quota_is_exhausted_and_pool_flag_enabled() {
|
||||||
let mut first = sample_row();
|
let mut first = sample_row_without_model_mappings();
|
||||||
first.provider_id = "provider-kiro".to_string();
|
first.provider_id = "provider-kiro".to_string();
|
||||||
first.provider_name = "kiro".to_string();
|
first.provider_name = "kiro".to_string();
|
||||||
first.provider_type = "kiro".to_string();
|
first.provider_type = "kiro".to_string();
|
||||||
@@ -2632,7 +2635,7 @@ async fn skips_kiro_candidate_when_account_quota_is_exhausted_and_pool_flag_enab
|
|||||||
first.key_api_formats = Some(vec!["claude:messages".to_string()]);
|
first.key_api_formats = Some(vec!["claude:messages".to_string()]);
|
||||||
first.key_global_priority_by_format = Some(serde_json::json!({"claude:messages": 1}));
|
first.key_global_priority_by_format = Some(serde_json::json!({"claude:messages": 1}));
|
||||||
|
|
||||||
let mut second = sample_row();
|
let mut second = sample_row_without_model_mappings();
|
||||||
second.provider_id = "provider-openai".to_string();
|
second.provider_id = "provider-openai".to_string();
|
||||||
second.provider_name = "openai".to_string();
|
second.provider_name = "openai".to_string();
|
||||||
second.endpoint_id = "endpoint-openai".to_string();
|
second.endpoint_id = "endpoint-openai".to_string();
|
||||||
|
|||||||
@@ -56,6 +56,14 @@ pub(super) fn sample_row() -> StoredMinimalCandidateSelectionRow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 共享夹具默认把上游名映射限定在 openai 格式;需要其它端点/格式的用例
|
||||||
|
/// 用本函数移除映射约束(无映射的行在所有端点按默认上游名可用)。
|
||||||
|
pub(super) fn sample_row_without_model_mappings() -> StoredMinimalCandidateSelectionRow {
|
||||||
|
let mut row = sample_row();
|
||||||
|
row.model_provider_model_mappings = None;
|
||||||
|
row
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn sample_provider(
|
pub(super) fn sample_provider(
|
||||||
id: &str,
|
id: &str,
|
||||||
concurrent_limit: Option<i32>,
|
concurrent_limit: Option<i32>,
|
||||||
|
|||||||
Reference in New Issue
Block a user