Skip to content

Commit

Permalink
fix: FFI Inmemory sink uses the global static LOG_BUFFER in the pac…
Browse files Browse the repository at this point in the history
…t_matching crate #434
  • Loading branch information
rholshausen committed Jun 11, 2024
1 parent b7869cd commit 278f56f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 49 deletions.
49 changes: 4 additions & 45 deletions rust/Cargo.lock

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

3 changes: 3 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ onig = { git = "https://github.com/rust-onig/rust-onig", default-features = fals
tracing = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing-subscriber-0.3.18" }
tracing-core = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing-subscriber-0.3.18" }
tracing-subscriber = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing-subscriber-0.3.18" }
# FFI Inmemory sink uses the global static `LOG_BUFFER` in the pact_matching crate. This is required to be the same
# version across all crates (i.e. mock server crate).
pact_matching = { version = "~1.2.3", path = "./pact_matching" }

[profile.release]
strip = true
Expand Down
11 changes: 7 additions & 4 deletions rust/pact_ffi/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1413,15 +1413,17 @@ fn matching_definition_expressions_matcher() {
// Run independently as this log settings are global, and other tests affect this one.
// cargo test -p pact_ffi returns_mock_server_logs -- --nocapture --include-ignored
#[ignore]
#[test]
#[test_log::test]
fn returns_mock_server_logs() {
let pact_json = include_str!("post-pact.json");
let pact_json_c = CString::new(pact_json).expect("Could not construct C string from json");
let address = CString::new("127.0.0.1:0").unwrap();

pactffi_log_to_buffer(LevelFilter::Debug.into());
#[allow(deprecated)]
let port = pactffi_create_mock_server(pact_json_c.as_ptr(), address.as_ptr(), false);
expect!(port).to(be_greater_than(0));
pactffi_log_to_buffer(LevelFilter::Debug.into());

let client = Client::default();
client.post(format!("http://127.0.0.1:{}/path", port).as_str())
.header(CONTENT_TYPE, "application/json")
Expand All @@ -1432,7 +1434,8 @@ fn returns_mock_server_logs() {
CStr::from_ptr(pactffi_mock_server_logs(port)).to_string_lossy().into_owned()
};
println!("{}",logs);
assert_ne!(logs,"", "logs are empty");

pactffi_cleanup_mock_server(port);
}

assert_ne!(logs,"", "logs are empty");
}

0 comments on commit 278f56f

Please sign in to comment.