Skip to content

Commit

Permalink
unittests for single lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
fayzanx committed Feb 14, 2023
1 parent e6c94fc commit bcfd18d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/ipinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ impl IpInfo {
&mut self,
ip: &str,
) -> Result<IpDetails, IpError> {

// Check for cache hit
let cached_detail = self.cache.get(&ip.to_string());

Expand Down Expand Up @@ -352,17 +351,16 @@ mod tests {
fn request_single_ip() {
let mut ipinfo = get_ipinfo_client();

let details = ipinfo.lookup_batch(&["66.87.125.72"]).expect("should lookup");
let details = ipinfo.lookup("66.87.125.72").expect("should lookup");

assert!(details.contains_key("66.87.125.72"));
assert_eq!(details.len(), 1);
assert_eq!(details.ip, "66.87.125.72");
}

#[test]
fn request_single_ip_no_token() {
fn request_no_token() {
let mut ipinfo =
IpInfo::new(Default::default()).expect("should construct");

assert_eq!(
ipinfo.lookup_batch(&["8.8.8.8"]).err().unwrap().kind(),
IpErrorKind::IpRequestError
Expand Down

0 comments on commit bcfd18d

Please sign in to comment.