Files
hickory-dns/crates/server/tests/timeout_stream_tests.rs
Benjamin Fry 408d0baca0 Prepare 0.24 release with branding change to Hickory DNS (#2054)
* update all READMEs with notices about the name change

* update changelog for 0.24

* bump crate versions to 0.24

* update version notice information

* update readmes to back reference trust-dns

* rename all crates to hickory counterparts

* replace all Trust-DNS references in code and comments with Hickory DNS

* rename all Trust-DNS references to Hickory DNS in non-code

* rename all trust-dns-resolver references to hickory-resolver

* rename all trust-dns-client references to hickory-client

* rename all trust-dns-proto references to hickory-proto

* rename all trust-dns-server references to hickory-server

* rename all trust-dns-compatibility references to hickory-compatability

* rename all trust-dns-integration references to hickory-integration

* rename all trust-dns-util references to hickory-util

* Update MIT licenses to reference Hickory DNS

* update all trust-dns references to hickory-dns

* update all bluejekyll github references to hickorydns org

* Update name in Changelog

* make sure hickory-dns logs during tests

* add changelogs for recent main additions

* fix references to trust-dns and hickory in architecture

* update a few trust-dns references in READMEs

* fixup some dangling trust_dns references

* replace fka with formerly in change log

* replace all hickoydns org references to hickory-dns

* replace all http links with https

* update logos

* update hickorydns to hickory-dns for all other org references

* fix Notices of Trust-DNS to Hickory in each Readme
2023-10-13 18:39:28 -07:00

55 lines
1.6 KiB
Rust

use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::Duration;
use futures_util::stream::{iter, Stream, StreamExt, TryStreamExt};
use tokio::runtime::Runtime;
use hickory_server::server::TimeoutStream;
#[test]
fn test_no_timeout() {
#[allow(deprecated)]
let sequence =
iter(vec![Ok(1), Err("error"), Ok(2)]).map_err(|e| io::Error::new(io::ErrorKind::Other, e));
let core = Runtime::new().expect("could not get core");
let timeout_stream = TimeoutStream::new(sequence, Duration::from_secs(360));
let (val, timeout_stream) = core.block_on(timeout_stream.into_future());
assert_eq!(val.expect("nothing in stream").ok(), Some(1));
let (error, timeout_stream) = core.block_on(timeout_stream.into_future());
assert!(error.expect("nothing in stream").is_err());
let (val, timeout_stream) = core.block_on(timeout_stream.into_future());
assert_eq!(val.expect("nothing in stream").ok(), Some(2));
let (val, _) = core.block_on(timeout_stream.into_future());
assert!(val.is_none())
}
struct NeverStream {}
impl Stream for NeverStream {
type Item = Result<(), io::Error>;
// somehow insert a timeout here...
fn poll_next(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> {
Poll::Pending
}
}
#[test]
fn test_timeout() {
let core = Runtime::new().expect("could not get core");
let timeout_stream = TimeoutStream::new(NeverStream {}, Duration::from_millis(1));
assert!(core
.block_on(timeout_stream.into_future())
.0
.expect("nothing in stream")
.is_err());
}