mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-09 20:50:20 +08:00
test(gateway): seed default routing strategy in request fixtures
This commit is contained in:
@@ -877,6 +877,34 @@ impl GatewayDataState {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Attach the minimal enabled system-default strategy needed by request
|
||||||
|
/// execution tests. Production startup creates this row during database
|
||||||
|
/// bootstrap; isolated test data states bypass that startup path.
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) fn with_default_routing_group_for_tests(self) -> Self {
|
||||||
|
use aether_data::repository::routing_profiles::InMemoryRoutingGroupRepository;
|
||||||
|
use aether_data_contracts::repository::routing_profiles::StoredRoutingGroup;
|
||||||
|
|
||||||
|
let repository = Arc::new(InMemoryRoutingGroupRepository::seed(
|
||||||
|
vec![StoredRoutingGroup {
|
||||||
|
id: "test-system-default".to_string(),
|
||||||
|
name: "test-system-default".to_string(),
|
||||||
|
description: None,
|
||||||
|
enabled: true,
|
||||||
|
is_system_default: true,
|
||||||
|
sort_order: 0,
|
||||||
|
config_json: serde_json::json!({}),
|
||||||
|
version: 1,
|
||||||
|
created_at: 1,
|
||||||
|
updated_at: 1,
|
||||||
|
published_at: None,
|
||||||
|
}],
|
||||||
|
Vec::new(),
|
||||||
|
Vec::new(),
|
||||||
|
));
|
||||||
|
self.with_routing_group_repository_for_tests(repository)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(crate) fn with_auth_api_key_reader(
|
pub(crate) fn with_auth_api_key_reader(
|
||||||
mut self,
|
mut self,
|
||||||
|
|||||||
@@ -17,6 +17,20 @@ use crate::{provider_transport, usage};
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
impl AppState {
|
impl AppState {
|
||||||
pub(crate) fn with_data_state_for_tests(mut self, data_state: GatewayDataState) -> Self {
|
pub(crate) fn with_data_state_for_tests(mut self, data_state: GatewayDataState) -> Self {
|
||||||
|
// Request-execution fixtures provide candidate and provider data but
|
||||||
|
// bypass the production startup bootstrap that creates the enabled
|
||||||
|
// system-default routing group. Keep those isolated states aligned
|
||||||
|
// with the real gateway contract while leaving intentionally disabled
|
||||||
|
// or routing-only fixtures untouched.
|
||||||
|
let data_state = if data_state.has_minimal_candidate_selection_reader()
|
||||||
|
&& data_state.has_provider_catalog_reader()
|
||||||
|
&& !data_state.has_routing_group_reader()
|
||||||
|
&& !data_state.has_routing_group_writer()
|
||||||
|
{
|
||||||
|
data_state.with_default_routing_group_for_tests()
|
||||||
|
} else {
|
||||||
|
data_state
|
||||||
|
};
|
||||||
self.replace_data_state(Arc::new(data_state));
|
self.replace_data_state(Arc::new(data_state));
|
||||||
self.request_candidate_queue = None;
|
self.request_candidate_queue = None;
|
||||||
self
|
self
|
||||||
|
|||||||
Reference in New Issue
Block a user