refactor: simplify upstream-path test — reuse pool mutex, drop narrating comment
This commit is contained in:
13
src/ctx.rs
13
src/ctx.rs
@@ -1256,9 +1256,6 @@ mod tests {
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn pipeline_default_pool_reports_upstream_path() {
|
async fn pipeline_default_pool_reports_upstream_path() {
|
||||||
// No forwarding rule matches — query falls through to the default
|
|
||||||
// [upstream] pool. Path must be reported as Upstream (not Forwarded)
|
|
||||||
// so operators can distinguish [[forwarding]] hits from pool traffic.
|
|
||||||
let mut upstream_resp = DnsPacket::new();
|
let mut upstream_resp = DnsPacket::new();
|
||||||
upstream_resp.header.response = true;
|
upstream_resp.header.response = true;
|
||||||
upstream_resp.header.rescode = ResultCode::NOERROR;
|
upstream_resp.header.rescode = ResultCode::NOERROR;
|
||||||
@@ -1269,11 +1266,11 @@ mod tests {
|
|||||||
});
|
});
|
||||||
let upstream_addr = crate::testutil::mock_upstream(upstream_resp).await;
|
let upstream_addr = crate::testutil::mock_upstream(upstream_resp).await;
|
||||||
|
|
||||||
let mut ctx = crate::testutil::test_ctx().await;
|
let ctx = crate::testutil::test_ctx().await;
|
||||||
ctx.upstream_pool = std::sync::Mutex::new(crate::forward::UpstreamPool::new(
|
ctx.upstream_pool
|
||||||
vec![Upstream::Udp(upstream_addr)],
|
.lock()
|
||||||
vec![],
|
.unwrap()
|
||||||
));
|
.set_primary(vec![Upstream::Udp(upstream_addr)]);
|
||||||
let ctx = Arc::new(ctx);
|
let ctx = Arc::new(ctx);
|
||||||
|
|
||||||
let (resp, path) = resolve_in_test(&ctx, "example.com", QueryType::A).await;
|
let (resp, path) = resolve_in_test(&ctx, "example.com", QueryType::A).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user