mirror of https://github.com/rwf2/Rocket.git
Clean up 'on_launch_fairing_can_inspect_port' test.
This commit is contained in:
parent
48fd83a31d
commit
407e346a6a
|
@ -1,23 +1,15 @@
|
|||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
||||
use rocket::config::Config;
|
||||
use rocket::fairing::AdHoc;
|
||||
use rocket::figment::Figment;
|
||||
use rocket::futures::channel::oneshot;
|
||||
|
||||
#[rocket::async_test]
|
||||
async fn on_launch_fairing_can_inspect_port() {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let mut config = Config::default();
|
||||
config.port = 0;
|
||||
tokio::spawn(
|
||||
rocket::custom(Figment::from(config))
|
||||
.mount("/", routes![])
|
||||
.attach(AdHoc::on_launch("Get assigned port", move |rocket| {
|
||||
tx.send(rocket.config().port).unwrap();
|
||||
}))
|
||||
.launch(),
|
||||
);
|
||||
assert!(rx.await.unwrap() != 0);
|
||||
let rocket = rocket::custom(Config { port: 0, ..Default::default() })
|
||||
.attach(AdHoc::on_launch("Send Port -> Channel", move |rocket| {
|
||||
tx.send(rocket.config().port).unwrap();
|
||||
}));
|
||||
|
||||
rocket::tokio::spawn(rocket.launch());
|
||||
assert_ne!(rx.await.unwrap(), 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue