From 762f68e911d9be3c51eabd491d201a2ca498c529 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Mon, 19 Feb 2024 06:05:57 +1100 Subject: [PATCH] feat(verifier): Add the verifier version to the published results #307 --- rust/pact_verifier/src/lib.rs | 2 ++ rust/pact_verifier/src/pact_broker.rs | 20 ++++++++++---------- rust/pact_verifier/src/tests.rs | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/rust/pact_verifier/src/lib.rs b/rust/pact_verifier/src/lib.rs index 8b91bb275..4094815c1 100644 --- a/rust/pact_verifier/src/lib.rs +++ b/rust/pact_verifier/src/lib.rs @@ -78,6 +78,8 @@ pub mod metrics; pub mod verification_result; mod utils; +const VERIFIER_VERSION: &str = env!("CARGO_PKG_VERSION"); + /// Source for loading pacts #[derive(Debug, Clone)] pub enum PactSource { diff --git a/rust/pact_verifier/src/pact_broker.rs b/rust/pact_verifier/src/pact_broker.rs index cc2e80518..52f5332d2 100644 --- a/rust/pact_verifier/src/pact_broker.rs +++ b/rust/pact_verifier/src/pact_broker.rs @@ -9,7 +9,7 @@ use anyhow::anyhow; use futures::stream::*; use itertools::Itertools; use maplit::hashmap; -use pact_models::{http_utils, PACT_RUST_VERSION}; +use pact_models::http_utils; use pact_models::http_utils::HttpAuth; use pact_models::json_utils::json_to_string; use pact_models::pact::{load_pact_from_json, Pact}; @@ -22,7 +22,7 @@ use tracing::{debug, error, info, trace, warn}; use pact_matching::Mismatch; -use crate::MismatchResult; +use crate::{MismatchResult, VERIFIER_VERSION}; use crate::utils::with_retries; fn is_true(object: &serde_json::Map, field: &str) -> bool { @@ -820,7 +820,7 @@ fn build_payload(result: TestResult, version: String, build_url: Option) "providerApplicationVersion": version, "verifiedBy": { "implementation": "Pact-Rust", - "version": PACT_RUST_VERSION + "version": VERIFIER_VERSION } }); let json_obj = json.as_object_mut().unwrap(); @@ -2025,7 +2025,7 @@ mod tests { "testResults": [], "verifiedBy": { "implementation": "Pact-Rust", - "version": PACT_RUST_VERSION + "version": VERIFIER_VERSION } }))); } @@ -2041,7 +2041,7 @@ mod tests { "testResults": [], "verifiedBy": { "implementation": "Pact-Rust", - "version": PACT_RUST_VERSION + "version": VERIFIER_VERSION } }))); } @@ -2061,7 +2061,7 @@ mod tests { ], "verifiedBy": { "implementation": "Pact-Rust", - "version": PACT_RUST_VERSION + "version": VERIFIER_VERSION } }))); } @@ -2076,7 +2076,7 @@ mod tests { "testResults": [], "verifiedBy": { "implementation": "Pact-Rust", - "version": PACT_RUST_VERSION + "version": VERIFIER_VERSION } }))); } @@ -2110,7 +2110,7 @@ mod tests { ], "verifiedBy": { "implementation": "Pact-Rust", - "version": PACT_RUST_VERSION + "version": VERIFIER_VERSION } }))); } @@ -2137,7 +2137,7 @@ mod tests { ], "verifiedBy": { "implementation": "Pact-Rust", - "version": PACT_RUST_VERSION + "version": VERIFIER_VERSION } }))); } @@ -2186,7 +2186,7 @@ mod tests { ], "verifiedBy": { "implementation": "Pact-Rust", - "version": PACT_RUST_VERSION + "version": VERIFIER_VERSION } }))); } diff --git a/rust/pact_verifier/src/tests.rs b/rust/pact_verifier/src/tests.rs index d510b291d..851bf6389 100644 --- a/rust/pact_verifier/src/tests.rs +++ b/rust/pact_verifier/src/tests.rs @@ -11,7 +11,6 @@ use expectest::prelude::*; use maplit::*; use pact_models::Consumer; use pact_models::pact::Pact; -use pact_models::PACT_RUST_VERSION; use pact_models::provider_states::*; use pact_models::sync_interaction::RequestResponseInteraction; use pact_models::sync_pact::RequestResponsePact; @@ -25,6 +24,7 @@ use crate::{NullRequestFilterExecutor, PactSource, ProviderInfo, ProviderStateEx use crate::callback_executors::HttpRequestProviderStateExecutor; use crate::pact_broker::Link; use crate::verification_result::VerificationInteractionResult; +use crate::VERIFIER_VERSION; use super::{execute_state_change, filter_consumers, filter_interaction, FilterInfo}; @@ -293,7 +293,7 @@ async fn publish_successful_result_to_broker() { ], "verifiedBy": json!({ "implementation": "Pact-Rust", - "version": PACT_RUST_VERSION + "version": VERIFIER_VERSION }) })); i.response.status(201);