From 2aa8016a6431f0582418852dee8df28d1f9499e9 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Mon, 29 Jan 2024 15:50:16 +1100 Subject: [PATCH] chore: Update flaky mock server test --- tests/mock_server_tests.rs | 39 +++----------------------------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/tests/mock_server_tests.rs b/tests/mock_server_tests.rs index d84bca6..95d195a 100644 --- a/tests/mock_server_tests.rs +++ b/tests/mock_server_tests.rs @@ -1,4 +1,3 @@ -use std::fs; use std::panic::catch_unwind; use std::path::Path; use base64::Engine; @@ -20,7 +19,7 @@ use pact_protobuf_plugin::utils::find_message_type_by_name; async fn mock_server_block() { let mut pact_builder = PactBuilderAsync::new_v4("null-and-void", "protobuf-plugin"); let _mock_server = pact_builder - .using_plugin("protobuf", Some("0".to_string())).await + .using_plugin("protobuf", None).await .synchronous_message_interaction("doesn't matter, won't be called", |mut i| async move { let proto_file = Path::new("tests/simple.proto") .canonicalize().unwrap().to_string_lossy().to_string(); @@ -48,37 +47,7 @@ async fn mock_server_block() { } #[test_log::test] -#[ignore] // TODO: This test sometimes fails with transport error and other times -// "application/protobuf;application/grpc" was not found in the plugin register fn mock_server_with_no_requests() { - let current_exe = std::env::current_exe().unwrap(); - let current_dir = current_exe.parent().unwrap(); - let test_bin_dir = current_dir.parent().unwrap(); - let plugin_bin = if cfg!(windows) { - test_bin_dir.join("pact-protobuf-plugin.exe") - } else { - test_bin_dir.join("pact-protobuf-plugin") - }; - - if plugin_bin.exists() { - let plugin_dir = home::home_dir().unwrap().join(".pact/plugins/protobuf-0"); - fs::create_dir_all(plugin_dir.clone()).unwrap(); - let manifest_file = plugin_dir.join("pact-plugin.json"); - fs::write(manifest_file, json!({ - "manifestVersion": 1, - "pluginInterfaceVersion": 1, - "name": "protobuf", - "version": "0", - "executableType": "exec", - "entryPoint": "pact-protobuf-plugin", - "pluginConfig": { - "protocVersion": "3.19.1", - "downloadUrl": "https://github.com/protocolbuffers/protobuf/releases/download" - } - }).to_string()).unwrap(); - let plugin_file = plugin_dir.join("pact-protobuf-plugin"); - fs::copy(plugin_bin, plugin_file).unwrap(); - let result = catch_unwind(|| { let runtime = tokio::runtime::Builder::new_multi_thread() .enable_all() @@ -87,12 +56,10 @@ fn mock_server_with_no_requests() { runtime.block_on(mock_server_block()) }); - fs::remove_dir_all(plugin_dir).unwrap(); - let error = result.unwrap_err(); let error_message = panic_message::panic_message(&error); - expect!(error_message).to(be_equal_to("plugin mock server failed verification:\n 1) Test/GetTest: Did not receive any requests for path 'Test/GetTest'\n")); - } + expect!(error_message).to(be_equal_to( + "plugin mock server failed verification:\n 1) Test/GetTest: Did not receive any requests for path 'Test/GetTest'\n")); } #[test_log::test(tokio::test(flavor = "multi_thread"))]