in components/search/src/environment_matching.rs [785:942]
fn test_matches_user_environment_versions() {
assert!(
!matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "43.0.0".to_string(),
max_version: "".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "42.0.0".to_string(),
..Default::default()
},
),
"Should return false when the version is below the minimum"
);
assert!(
matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "42.0.0".to_string(),
max_version: "".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "42.0.0".to_string(),
..Default::default()
},
),
"Should return true when the version is equal to the minimum"
);
assert!(
matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "41.0.0".to_string(),
max_version: "".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "42.0.0".to_string(),
..Default::default()
},
),
"Should return true when the version is above the minimum"
);
assert!(
matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "".to_string(),
max_version: "43.0.0".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "42.0.0".to_string(),
..Default::default()
},
),
"Should return true when the version is below the maximum"
);
assert!(
matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "".to_string(),
max_version: "42.0.0".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "42.0.0".to_string(),
..Default::default()
},
),
"Should return true when the version is equal to the maximum"
);
assert!(
!matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "".to_string(),
max_version: "41.0.0".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "42.0.0".to_string(),
..Default::default()
},
),
"Should return false when the version is above the maximum"
);
assert!(
!matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "41.0.0".to_string(),
max_version: "43.0.0".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "2.0.0".to_string(),
..Default::default()
},
),
"Should return false when the version is below the minimum and both are specified"
);
assert!(
matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "41.0.0".to_string(),
max_version: "43.0.0".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "41.0.0".to_string(),
..Default::default()
},
),
"Should return true when the version is equal to the minimum and both are specified"
);
assert!(
matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "41.0.0".to_string(),
max_version: "43.0.0".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "42.0.0".to_string(),
..Default::default()
},
),
"Should return true when the version is between the minimum and maximum"
);
assert!(
matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "41.0.0".to_string(),
max_version: "43.0.0".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "43.0.0".to_string(),
..Default::default()
},
),
"Should return true when the version is equal to the maximum and both are specified"
);
assert!(
!matches_user_environment(
&crate::JSONVariantEnvironment {
min_version: "41.0.0".to_string(),
max_version: "43.0.0".to_string(),
..Default::default()
},
&SearchUserEnvironment {
version: "44.0.0".to_string(),
..Default::default()
},
),
"Should return false when the version is above the maximum and both are specified"
);
}