-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add an integration test for realtime stopmonitoring
- Loading branch information
1 parent
a166538
commit 07176e0
Showing
5 changed files
with
179 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
use chrono::NaiveDate; | ||
use prost::Message; | ||
|
||
const SERVER_PATH: &str = "/gtfs_rt"; | ||
|
||
pub fn make_test_server() -> actix_web::test::TestServer { | ||
env_logger::Builder::from_env(env_logger::Env::default()).init(); | ||
let begin = NaiveDate::from_ymd(2018, 12, 15); | ||
let period = transpo_rt::context::Period { | ||
begin: begin.clone(), | ||
end: begin.succ(), | ||
}; | ||
let ctx = transpo_rt::server::make_context("fixtures/gtfs.zip", "", &period); | ||
let gtfs_rt_server = mockito::SERVER_URL.to_string() + SERVER_PATH; | ||
let ctx = transpo_rt::server::make_context("fixtures/gtfs.zip", >fs_rt_server, &period); | ||
let make_server = move || transpo_rt::server::create_server(ctx.clone()); | ||
|
||
actix_web::test::TestServer::with_factory(make_server) | ||
} | ||
|
||
pub fn run_simple_gtfs_rt_server( | ||
gtfs_rt: transpo_rt::transit_realtime::FeedMessage, | ||
) -> mockito::Mock { | ||
let mut buf = vec![]; | ||
gtfs_rt | ||
.encode(&mut buf) | ||
.expect("impossible to convert the gtfs_rt to protobuf"); | ||
mockito::mock("GET", SERVER_PATH) | ||
.with_status(200) | ||
.with_header("content-type", "application/octet-stream") | ||
.with_body(buf) | ||
.create() | ||
} |