fix: replace unstable is_multiple_of with modulo and fix flaky temp test
The `is_multiple_of` method is unstable before Rust 1.87, breaking Docker builds that use rust:1.83-slim. Also merges the two temperature env-var tests into one to eliminate the race condition when tests run in parallel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b931aeb56c
commit
6f64099a48
2 changed files with 10 additions and 13 deletions
|
|
@ -1613,26 +1613,23 @@ default_temperature = 0.7
|
|||
|
||||
#[test]
|
||||
fn env_override_temperature() {
|
||||
// Both temperature cases tested in one function to avoid env-var
|
||||
// races when tests run in parallel.
|
||||
std::env::remove_var("ZEROCLAW_TEMPERATURE");
|
||||
let mut config = Config::default();
|
||||
|
||||
// Valid temperature is applied
|
||||
let mut config = Config::default();
|
||||
std::env::set_var("ZEROCLAW_TEMPERATURE", "0.5");
|
||||
config.apply_env_overrides();
|
||||
assert!((config.default_temperature - 0.5).abs() < f64::EPSILON);
|
||||
|
||||
std::env::remove_var("ZEROCLAW_TEMPERATURE");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn env_override_temperature_out_of_range_ignored() {
|
||||
std::env::remove_var("ZEROCLAW_TEMPERATURE");
|
||||
let mut config = Config::default();
|
||||
let original_temp = config.default_temperature;
|
||||
|
||||
// Out-of-range temperature is ignored
|
||||
let mut config2 = Config::default();
|
||||
let original_temp = config2.default_temperature;
|
||||
std::env::set_var("ZEROCLAW_TEMPERATURE", "3.0");
|
||||
config.apply_env_overrides();
|
||||
config2.apply_env_overrides();
|
||||
assert!(
|
||||
(config.default_temperature - original_temp).abs() < f64::EPSILON,
|
||||
(config2.default_temperature - original_temp).abs() < f64::EPSILON,
|
||||
"Temperature 3.0 should be ignored (out of range)"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ fn hex_encode(data: &[u8]) -> String {
|
|||
/// Hex-decode a hex string to bytes.
|
||||
#[allow(clippy::manual_is_multiple_of)]
|
||||
fn hex_decode(hex: &str) -> Result<Vec<u8>> {
|
||||
if !hex.len().is_multiple_of(2) {
|
||||
if hex.len() % 2 != 0 {
|
||||
anyhow::bail!("Hex string has odd length");
|
||||
}
|
||||
(0..hex.len())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue