test: reuse routers in workspace config fixtures
This commit is contained in:
@@ -54,7 +54,8 @@ impl agen::llm_client::LlmClient for ConfigNoopLlmClient {
|
|||||||
// No fake config provider, copied tree, or fabricated attachment ledger is used.
|
// No fake config provider, copied tree, or fabricated attachment ledger is used.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct ConfigRouterClient {
|
struct ConfigRouterClient {
|
||||||
api: WorkspaceApi,
|
// Reuse routing setup as serve() does; authentication and store reads still run per request.
|
||||||
|
router: Router,
|
||||||
worker: RuntimeWorkerRef,
|
worker: RuntimeWorkerRef,
|
||||||
identity: Arc<RuntimeIdentityMaterial>,
|
identity: Arc<RuntimeIdentityMaterial>,
|
||||||
runtime: tokio::runtime::Handle,
|
runtime: tokio::runtime::Handle,
|
||||||
@@ -95,7 +96,7 @@ impl worker::WorkspaceClient for ConfigRouterClient {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.push(format!("{method} {}", request.path));
|
.push(format!("{method} {}", request.path));
|
||||||
let is_commit = request.path.ends_with("/commit");
|
let is_commit = request.path.ends_with("/commit");
|
||||||
let api = self.api.clone();
|
let router = self.router.clone();
|
||||||
let identity = self.identity.clone();
|
let identity = self.identity.clone();
|
||||||
let worker = self.worker.clone();
|
let worker = self.worker.clone();
|
||||||
let runtime = self.runtime.clone();
|
let runtime = self.runtime.clone();
|
||||||
@@ -111,7 +112,7 @@ impl worker::WorkspaceClient for ConfigRouterClient {
|
|||||||
&request.path,
|
&request.path,
|
||||||
body,
|
body,
|
||||||
);
|
);
|
||||||
let response = build_router(api)
|
let response = router
|
||||||
.oneshot(signed)
|
.oneshot(signed)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| Failure::Request("router dispatch failed".into()))?;
|
.map_err(|_| Failure::Request("router dispatch failed".into()))?;
|
||||||
@@ -304,7 +305,7 @@ impl ConfigBatchWipFixture {
|
|||||||
grant(&backend.api, &backend.worker, Access::ReadWrite).await;
|
grant(&backend.api, &backend.worker, Access::ReadWrite).await;
|
||||||
attach(&backend.api, &backend.worker).await;
|
attach(&backend.api, &backend.worker).await;
|
||||||
let client = Arc::new(ConfigRouterClient {
|
let client = Arc::new(ConfigRouterClient {
|
||||||
api: backend.api.clone(),
|
router: build_router(backend.api.clone()),
|
||||||
worker: backend.worker.clone(),
|
worker: backend.worker.clone(),
|
||||||
identity: Arc::new(identity),
|
identity: Arc::new(identity),
|
||||||
runtime: tokio::runtime::Handle::current(),
|
runtime: tokio::runtime::Handle::current(),
|
||||||
@@ -873,7 +874,7 @@ async fn workspace_config_real_selected_invoke_backend_wip_edit_create_delete_im
|
|||||||
configure_runtime_request_auth(&mut fixture.api, &identity, &fixture.worker.runtime_id);
|
configure_runtime_request_auth(&mut fixture.api, &identity, &fixture.worker.runtime_id);
|
||||||
let granted = grant(&fixture.api, &fixture.worker, Access::ReadWrite).await;
|
let granted = grant(&fixture.api, &fixture.worker, Access::ReadWrite).await;
|
||||||
let client = Arc::new(ConfigRouterClient {
|
let client = Arc::new(ConfigRouterClient {
|
||||||
api: fixture.api.clone(),
|
router: build_router(fixture.api.clone()),
|
||||||
worker: fixture.worker.clone(),
|
worker: fixture.worker.clone(),
|
||||||
identity: Arc::new(identity),
|
identity: Arc::new(identity),
|
||||||
runtime: tokio::runtime::Handle::current(),
|
runtime: tokio::runtime::Handle::current(),
|
||||||
|
|||||||
Reference in New Issue
Block a user