Skip to content

Commit

Permalink
fix: test no_resource_available
Browse files Browse the repository at this point in the history
  • Loading branch information
joalopez1206 committed Oct 14, 2024
1 parent 40f9d44 commit 8626b28
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

use std::{net::IpAddr, str::FromStr};
use dns_rust::{async_resolver::{config::ResolverConfig, AsyncResolver}, client::client_error::ClientError, domain_name::DomainName, message::{rclass::Rclass, rdata::Rdata, resource_record::{ResourceRecord, ToBytes}, rrtype::Rrtype, DnsMessage}};



use dns_rust::async_resolver::lookup_response::LookupResponse;

// TODO: Change params type to intoDomainName
async fn query_response(domain_name: &str, protocol: &str, qtype: &str) -> Result<Vec<ResourceRecord>, ClientError> {
Expand All @@ -15,10 +13,16 @@ async fn query_response(domain_name: &str, protocol: &str, qtype: &str) -> Resul
domain_name,
protocol,
qtype,

"IN").await;

response.map(|lookup_response| lookup_response.to_vec_of_rr())
// TODO: a resolver always gets a response ??
match response {
Ok(lookup_resp) => {
Ok(lookup_resp.to_vec_of_rr())
}
Err(e) => {
Err(e)
}
}
}

/// 6.2.1 Query test Qtype = A
Expand Down Expand Up @@ -108,9 +112,11 @@ async fn mistyped_host_name() {

/// No record test
#[tokio::test]
// This test asserts if the resolver does not get an answer the length of the extracted answers should be 0
async fn no_resource_available() {
let response = query_response("example.com", "UDP", "CNAME").await;
println!("{:?}", response);
assert!(response.is_err());
//println!("{:?}", response);
let answers = response.unwrap();
assert_eq!(answers.len(), 0);
}

0 comments on commit 8626b28

Please sign in to comment.