zone: move iter_records to test

This commit is contained in:
Luna Yao
2026-04-06 02:30:46 +02:00
parent 4ed111dd04
commit 0cd92ff215
+17 -15
View File
@@ -4,7 +4,7 @@ use crate::dns::utils::authority::ArcAuthority;
use crate::proto;
use crate::proto::utils::RepeatedMessageModel;
use crate::utils::MapTryInto;
use hickory_proto::rr::{LowerName, Record, RecordSet, RrKey, RrsetRecords};
use hickory_proto::rr::{LowerName, RecordSet, RrKey};
use hickory_proto::serialize::txt::Parser;
use hickory_resolver::config::ResolverOpts;
use hickory_resolver::name_server::TokioConnectionProvider;
@@ -78,19 +78,6 @@ impl Zone {
.map(|f| Arc::new(f) as ArcAuthority)
})
}
// TODO: remove this
pub fn iter_records(&self) -> impl Iterator<Item = &Record> {
self.records
.values()
.filter(|set| !set.is_empty())
.flat_map(|set| {
let RrsetRecords::RecordsOnly(records) = set.records_without_rrsigs() else {
unreachable!()
};
records
})
}
}
impl TryFrom<&proto::dns::ZoneData> for Zone {
@@ -181,7 +168,7 @@ mod tests {
use crate::dns::utils::response::ResponseHandle;
use hickory_client::client::{Client, ClientHandle};
use hickory_proto::op::{Message, MessageType, OpCode, Query, ResponseCode};
use hickory_proto::rr::{rdata, DNSClass, Name, RData, RecordType};
use hickory_proto::rr::{rdata, DNSClass, Name, RData, Record, RecordType, RrsetRecords};
use hickory_proto::runtime::TokioRuntimeProvider;
use hickory_proto::serialize::binary::{BinDecodable, BinEncodable, BinEncoder};
use hickory_proto::udp::UdpClientStream;
@@ -196,6 +183,21 @@ mod tests {
use tokio::spawn;
use tokio::time::timeout;
impl Zone {
// TODO: remove this
pub fn iter_records(&self) -> impl Iterator<Item = &Record> {
self.records
.values()
.filter(|set| !set.is_empty())
.flat_map(|set| {
let RrsetRecords::RecordsOnly(records) = set.records_without_rrsigs() else {
unreachable!()
};
records
})
}
}
const CONFIG: &str = r#"
listeners = [
"127.0.0.1:5353",