Skip to content

Commit b56e489

Browse files
committed
add mx query integration test
1 parent e84828d commit b56e489

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

tests/integration_test.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,30 @@ async fn query_all_type() {
4848
}
4949
}
5050

51-
// TODO: 6.2.3 Query Qtype = MX
51+
/// 6.2.3 Query Qtype = MX
52+
#[tokio::test]
5253
async fn query_mx_type() {
53-
unimplemented!();
54+
let response = query_response("example.com", "MX").await;
55+
56+
if let Ok(rrs) = response {
57+
assert_eq!(rrs.len(), 1);
58+
59+
if let Rdata::MX(mxdata) = rrs[0].get_rdata() {
60+
assert_eq!(
61+
mxdata.get_exchange(),
62+
DomainName::new_from_str(""));
63+
64+
assert_eq!(
65+
mxdata.get_preference(),
66+
0
67+
)
68+
} else {
69+
panic!("Record is not MX type");
70+
}
71+
72+
} else {
73+
panic!("No response received")
74+
}
5475
}
5576

5677

@@ -66,15 +87,15 @@ async fn query_ns_type() {
6687
ns1.get_nsdname(),
6788
DomainName::new_from_str("a.iana-servers.net"))
6889
} else {
69-
panic!("First record is not type NS");
90+
panic!("First record is not NS");
7091
}
7192

7293
if let Rdata::NS(ns) = rrs[1].get_rdata() {
7394
assert_eq!(
7495
ns.get_nsdname(),
7596
DomainName::new_from_str("b.iana-servers.net"))
7697
} else {
77-
panic!("Second record is not type NS");
98+
panic!("Second record is not NS");
7899
}
79100

80101
} else {

0 commit comments

Comments
 (0)