Skip to content

Commit

Permalink
feat(verifier): Add the verifier version to the published results #307
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Feb 18, 2024
1 parent 167c445 commit 762f68e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions rust/pact_verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions rust/pact_verifier/src/pact_broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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<String, Value>, field: &str) -> bool {
Expand Down Expand Up @@ -820,7 +820,7 @@ fn build_payload(result: TestResult, version: String, build_url: Option<String>)
"providerApplicationVersion": version,
"verifiedBy": {
"implementation": "Pact-Rust",
"version": PACT_RUST_VERSION
"version": VERIFIER_VERSION
}
});
let json_obj = json.as_object_mut().unwrap();
Expand Down Expand Up @@ -2025,7 +2025,7 @@ mod tests {
"testResults": [],
"verifiedBy": {
"implementation": "Pact-Rust",
"version": PACT_RUST_VERSION
"version": VERIFIER_VERSION
}
})));
}
Expand All @@ -2041,7 +2041,7 @@ mod tests {
"testResults": [],
"verifiedBy": {
"implementation": "Pact-Rust",
"version": PACT_RUST_VERSION
"version": VERIFIER_VERSION
}
})));
}
Expand All @@ -2061,7 +2061,7 @@ mod tests {
],
"verifiedBy": {
"implementation": "Pact-Rust",
"version": PACT_RUST_VERSION
"version": VERIFIER_VERSION
}
})));
}
Expand All @@ -2076,7 +2076,7 @@ mod tests {
"testResults": [],
"verifiedBy": {
"implementation": "Pact-Rust",
"version": PACT_RUST_VERSION
"version": VERIFIER_VERSION
}
})));
}
Expand Down Expand Up @@ -2110,7 +2110,7 @@ mod tests {
],
"verifiedBy": {
"implementation": "Pact-Rust",
"version": PACT_RUST_VERSION
"version": VERIFIER_VERSION
}
})));
}
Expand All @@ -2137,7 +2137,7 @@ mod tests {
],
"verifiedBy": {
"implementation": "Pact-Rust",
"version": PACT_RUST_VERSION
"version": VERIFIER_VERSION
}
})));
}
Expand Down Expand Up @@ -2186,7 +2186,7 @@ mod tests {
],
"verifiedBy": {
"implementation": "Pact-Rust",
"version": PACT_RUST_VERSION
"version": VERIFIER_VERSION
}
})));
}
Expand Down
4 changes: 2 additions & 2 deletions rust/pact_verifier/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 762f68e

Please sign in to comment.