Skip to content

Commit

Permalink
Improve coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
xnuter committed Sep 23, 2020
1 parent d4db9bd commit 71af0d7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
![Clippy/Fmt](https://github.com/xnuter/http-tunnel/workflows/Clippy/Fmt/badge.svg)
![Tests](https://github.com/xnuter/http-tunnel/workflows/Tests/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/xnuter/service-benchmark/badge.svg?branch=master)](https://coveralls.io/github/xnuter/service-benchmark?branch=master)

Overview
========

Expand Down
42 changes: 38 additions & 4 deletions src/http_bench_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ mod tests {
use crate::bench_session::BenchClient;
use crate::http_bench_session::{HttpBenchmark, HttpBenchmarkBuilder};
use mockito::mock;
use std::time::Duration;
use tokio::time::timeout;

#[tokio::test]
async fn test_success_request() {
Expand Down Expand Up @@ -128,11 +130,11 @@ mod tests {
let http_bench: HttpBenchmark = HttpBenchmarkBuilder::default()
.url(format!("{}/1", url))
.tunnel(None)
.ignore_cert(true)
.conn_reuse(true)
.store_cookies(true)
.ignore_cert(false)
.conn_reuse(false)
.store_cookies(false)
.http2_only(false)
.verbose(false)
.verbose(true)
.build()
.unwrap();

Expand All @@ -145,4 +147,36 @@ mod tests {
assert_eq!(body.len(), stats.bytes_processed);
assert_eq!("500 Internal Server Error".to_string(), stats.status);
}

#[tokio::test]
async fn test_only_http2() {
let body = "world";

let _m = mock("GET", "/1")
.with_status(500)
.with_header("content-type", "text/plain")
.with_body(body)
.create();

let url = mockito::server_url().to_string();
println!("Url: {}", url);
let http_bench: HttpBenchmark = HttpBenchmarkBuilder::default()
.url(format!("{}/1", url))
.tunnel(None)
.ignore_cert(false)
.conn_reuse(false)
.store_cookies(false)
.http2_only(true)
.verbose(true)
.build()
.unwrap();

let client = http_bench.build_client().expect("Client is built");
let result = timeout(Duration::from_secs(1), http_bench.send_request(&client)).await;

assert!(
result.is_err(),
"Expected to fail as h2 is not supported by the endpoint"
);
}
}

0 comments on commit 71af0d7

Please sign in to comment.