0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/rust/feature-flags/tests/test_flag_matching_consistency.rs
2024-11-19 18:03:23 -05:00

1258 lines
42 KiB
Rust

use std::sync::Arc;
/// These tests are common between all libraries doing local evaluation of feature flags.
/// This ensures there are no mismatches between implementations.
use feature_flags::{
cohort::cohort_cache_manager::CohortCacheManager,
flags::{
flag_match_reason::FeatureFlagMatchReason,
flag_matching::{FeatureFlagMatch, FeatureFlagMatcher},
},
utils::test_utils::{create_flag_from_json, setup_pg_reader_client, setup_pg_writer_client},
};
use serde_json::json;
#[tokio::test]
async fn it_is_consistent_with_rollout_calculation_for_simple_flags() {
let flags = create_flag_from_json(Some(
json!([{
"id": 1,
"key": "simple-flag",
"name": "Simple flag",
"active": true,
"deleted": false,
"team_id": 1,
"filters": {
"groups": [
{
"properties": [],
"rollout_percentage": 45,
},
],
},
}])
.to_string(),
));
let results = vec![
false, true, true, false, true, false, false, true, false, true, false, true, true, false,
true, false, false, false, true, true, false, true, false, false, true, false, true, true,
false, false, false, true, true, true, true, false, false, false, false, false, false,
true, true, false, true, true, false, false, false, true, true, false, false, false, false,
true, false, true, false, true, false, true, true, false, true, false, true, false, true,
true, false, false, true, false, false, true, false, true, false, false, true, false,
false, false, true, true, false, true, true, false, true, true, true, true, true, false,
true, true, false, false, true, true, true, true, false, false, true, false, true, true,
true, false, false, false, false, false, true, false, false, true, true, true, false,
false, true, false, true, false, false, true, false, false, false, false, false, false,
false, false, true, true, false, false, true, false, false, true, true, false, false, true,
false, true, false, true, true, true, false, false, false, true, false, false, false,
false, true, true, false, true, true, false, true, false, true, true, false, true, false,
true, true, true, false, true, false, false, true, true, false, true, false, true, true,
false, false, true, true, true, true, false, true, true, false, false, true, false, true,
false, false, true, true, false, true, false, true, false, false, false, false, false,
false, false, true, false, true, true, false, false, true, false, true, false, false,
false, true, false, true, false, false, false, true, false, false, true, false, true, true,
false, false, false, false, true, false, false, false, false, false, false, false, false,
false, false, false, false, false, true, true, false, true, false, true, true, false, true,
false, true, false, false, false, true, true, true, true, false, false, false, false,
false, true, true, true, false, false, true, true, false, false, false, false, false, true,
false, true, true, true, true, false, true, true, true, false, false, true, false, true,
false, false, true, true, true, false, true, false, false, false, true, true, false, true,
false, true, false, true, true, true, true, true, false, false, true, false, true, false,
true, true, true, false, true, false, true, true, false, true, true, true, true, true,
false, false, false, false, false, true, false, true, false, false, true, true, false,
false, false, true, false, true, true, true, true, false, false, false, false, true, true,
false, false, true, true, false, true, true, true, true, false, true, true, true, false,
false, true, true, false, false, true, false, false, true, false, false, false, false,
false, false, false, false, false, false, true, true, false, false, true, false, false,
true, false, true, false, false, true, false, false, false, false, false, false, true,
false, false, false, false, false, false, false, false, false, true, true, true, false,
false, false, true, false, true, false, false, false, true, false, false, false, false,
false, false, false, true, false, false, false, false, false, false, false, false, true,
false, true, false, true, true, true, false, false, false, true, true, true, false, true,
false, true, true, false, false, false, true, false, false, false, false, true, false,
true, false, true, true, false, true, false, false, false, true, false, false, true, true,
false, true, false, false, false, false, false, false, true, true, false, false, true,
false, false, true, true, true, false, false, false, true, false, false, false, false,
true, false, true, false, false, false, true, false, true, true, false, true, false, true,
false, true, false, false, true, false, false, true, false, true, false, true, false, true,
false, false, true, true, true, true, false, true, false, false, false, false, false, true,
false, false, true, false, false, true, true, false, false, false, false, true, true, true,
false, false, true, false, false, true, true, true, true, false, false, false, true, false,
false, false, true, false, false, true, true, true, true, false, false, true, true, false,
true, false, true, false, false, true, true, false, true, true, true, true, false, false,
true, false, false, true, true, false, true, false, true, false, false, true, false, false,
false, false, true, true, true, false, true, false, false, true, false, false, true, false,
false, false, false, true, false, true, false, true, true, false, false, true, false, true,
true, true, false, false, false, false, true, true, false, true, false, false, false, true,
false, false, false, false, true, true, true, false, false, false, true, true, true, true,
false, true, true, false, true, true, true, false, true, false, false, true, false, true,
true, true, true, false, true, false, true, false, true, false, false, true, true, false,
false, true, false, true, false, false, false, false, true, false, true, false, false,
false, true, true, true, false, false, false, true, false, true, true, false, false, false,
false, false, true, false, true, false, false, true, true, false, true, true, true, true,
false, false, true, false, false, true, false, true, false, true, true, false, false,
false, true, false, true, true, false, false, false, true, false, true, false, true, true,
false, true, false, false, true, false, false, false, true, true, true, false, false,
false, false, false, true, false, false, true, true, true, true, true, false, false, false,
false, false, false, false, false, true, true, true, false, false, true, true, false, true,
true, false, true, false, true, false, false, false, true, false, false, true, false,
false, true, true, true, true, false, false, true, false, true, true, false, false, true,
false, false, true, true, false, true, false, false, true, true, true, false, false, false,
false, false, true, false, true, false, false, false, false, false, true, true, false,
true, true, true, false, false, false, false, true, true, true, true, false, true, true,
false, true, false, true, false, true, false, false, false, false, true, true, true, true,
false, false, true, false, true, true, false, false, false, false, false, false, true,
false, true, false, true, true, false, false, true, true, true, true, false, false, true,
false, true, true, false, false, true, true, true, false, true, false, false, true, true,
false, false, false, true, false, false, true, false, false, false, true, true, true, true,
false, true, false, true, false, true, false, true, false, false, true, false, false, true,
false, true, true,
];
for (i, result) in results.iter().enumerate().take(1000) {
let postgres_reader = setup_pg_reader_client(None).await;
let postgres_writer = setup_pg_writer_client(None).await;
let cohort_cache = Arc::new(CohortCacheManager::new(postgres_reader.clone(), None, None));
let distinct_id = format!("distinct_id_{}", i);
let feature_flag_match = FeatureFlagMatcher::new(
distinct_id,
1,
postgres_reader,
postgres_writer,
cohort_cache,
None,
None,
)
.get_match(&flags[0], None, None)
.await
.unwrap();
if *result {
assert_eq!(
feature_flag_match,
FeatureFlagMatch {
matches: true,
variant: None,
reason: FeatureFlagMatchReason::ConditionMatch,
condition_index: Some(0),
payload: None,
}
);
} else {
assert_eq!(
feature_flag_match,
FeatureFlagMatch {
matches: false,
variant: None,
reason: FeatureFlagMatchReason::OutOfRolloutBound,
condition_index: Some(0),
payload: None,
}
);
}
}
}
#[tokio::test]
async fn it_is_consistent_with_rollout_calculation_for_multivariate_flags() {
let flags = create_flag_from_json(Some(
json!([{
"id": 1,
"key": "multivariate-flag",
"name": "Multivariate flag",
"active": true,
"deleted": false,
"team_id": 1,
"filters": {
"groups": [
{
"properties": [],
"rollout_percentage": 55,
},
],
"multivariate": {
"variants": [
{
"key": "first-variant",
"name": "First Variant",
"rollout_percentage": 50,
},
{
"key": "second-variant",
"name": "Second Variant",
"rollout_percentage": 20,
},
{
"key": "third-variant",
"name": "Third Variant",
"rollout_percentage": 20,
},
{
"key": "fourth-variant",
"name": "Fourth Variant",
"rollout_percentage": 5,
},
{
"key": "fifth-variant",
"name": "Fifth Variant",
"rollout_percentage": 5,
},
],
},
},
}])
.to_string(),
));
let results = vec![
Some("second-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("fourth-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
Some("fifth-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
None,
None,
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
Some("fifth-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("fifth-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("fourth-variant".to_string()),
None,
None,
None,
None,
Some("third-variant".to_string()),
None,
None,
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("second-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
None,
None,
Some("second-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("fifth-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("second-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("fifth-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
None,
Some("third-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
None,
Some("third-variant".to_string()),
None,
None,
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
Some("fourth-variant".to_string()),
Some("fourth-variant".to_string()),
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("fifth-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("fifth-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("second-variant".to_string()),
Some("fifth-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
None,
Some("third-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("fifth-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("fourth-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("fifth-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("fourth-variant".to_string()),
Some("fifth-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
None,
Some("third-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
None,
None,
Some("third-variant".to_string()),
Some("fourth-variant".to_string()),
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
None,
Some("fourth-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("fourth-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("fourth-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("fifth-variant".to_string()),
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("fourth-variant".to_string()),
None,
None,
None,
Some("fourth-variant".to_string()),
None,
None,
Some("third-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("second-variant".to_string()),
None,
None,
Some("fifth-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
None,
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("third-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
None,
None,
None,
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
None,
None,
None,
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
None,
None,
Some("second-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("fifth-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
None,
None,
None,
None,
None,
Some("fourth-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("fifth-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("fifth-variant".to_string()),
None,
None,
Some("third-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("fifth-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("third-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
None,
Some("second-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("fifth-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("fifth-variant".to_string()),
None,
None,
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("second-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
None,
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
Some("second-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("second-variant".to_string()),
None,
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("fifth-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("fourth-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("fifth-variant".to_string()),
None,
None,
None,
Some("second-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("second-variant".to_string()),
None,
None,
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("third-variant".to_string()),
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
None,
None,
Some("first-variant".to_string()),
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("third-variant".to_string()),
Some("second-variant".to_string()),
Some("third-variant".to_string()),
None,
None,
Some("third-variant".to_string()),
Some("first-variant".to_string()),
None,
Some("first-variant".to_string()),
];
for (i, result) in results.iter().enumerate().take(1000) {
let postgres_reader = setup_pg_reader_client(None).await;
let postgres_writer = setup_pg_writer_client(None).await;
let cohort_cache = Arc::new(CohortCacheManager::new(postgres_reader.clone(), None, None));
let distinct_id = format!("distinct_id_{}", i);
let feature_flag_match = FeatureFlagMatcher::new(
distinct_id,
1,
postgres_reader,
postgres_writer,
cohort_cache,
None,
None,
)
.get_match(&flags[0], None, None)
.await
.unwrap();
if let Some(variant) = &result {
assert_eq!(
feature_flag_match,
FeatureFlagMatch {
matches: true,
variant: Some(variant.clone()),
reason: FeatureFlagMatchReason::ConditionMatch,
condition_index: Some(0),
payload: None,
}
);
} else {
assert_eq!(
feature_flag_match,
FeatureFlagMatch {
matches: false,
variant: None,
reason: FeatureFlagMatchReason::OutOfRolloutBound,
condition_index: Some(0),
payload: None,
}
);
}
}
}