Skip to content

Commit

Permalink
Update to libcnb-test 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
edmorley committed Jul 21, 2022
1 parent 2904e41 commit becc563
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ flate2 = { version = "1.0.23", default-features = false, features = ["zlib"] }
tar = "0.4.38"

[dev-dependencies]
libcnb-test = "0.5"
libcnb-test = "0.6"
32 changes: 15 additions & 17 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![warn(clippy::pedantic)]

use libcnb_test::{assert_contains, assert_not_contains, TestConfig, TestRunner};
use libcnb_test::{assert_contains, assert_not_contains, BuildConfig, ContainerConfig, TestRunner};
use std::time::Duration;

fn test_go_fixture(
Expand All @@ -9,8 +9,8 @@ fn test_go_fixture(
expect_loglines: &[&str],
refute_loglines: &[&str],
) {
TestRunner::default().run_test(
TestConfig::new(builder, format!("tests/fixtures/{fixture}")),
TestRunner::default().build(
BuildConfig::new(builder, format!("tests/fixtures/{fixture}")),
|ctx| {
let logs = format!("{}\n{}", ctx.pack_stdout, ctx.pack_stderr);
for expect_line in expect_loglines {
Expand All @@ -21,21 +21,19 @@ fn test_go_fixture(
}

let port = 8080;
ctx.prepare_container()
.expose_port(port)
.start_with_default_process(|container| {
std::thread::sleep(Duration::from_secs(5));
let addr = container
.address_for_port(port)
.expect("couldn't get container address");
let resp = ureq::get(&format!("http://{addr}"))
.call()
.expect("request to container failed")
.into_string()
.expect("response read error");
ctx.start_container(ContainerConfig::new().expose_port(port), |container| {
std::thread::sleep(Duration::from_secs(5));
let addr = container
.address_for_port(port)
.expect("couldn't get container address");
let resp = ureq::get(&format!("http://{addr}"))
.call()
.expect("request to container failed")
.into_string()
.expect("response read error");

assert_contains!(resp, fixture);
});
assert_contains!(resp, fixture);
});
},
);
}
Expand Down

0 comments on commit becc563

Please sign in to comment.