Skip to content

Commit 8ae755d

Browse files
aepfliCopilot
andcommitted
fix(fractional): fix integration tests after return type change to Value
Update two callers in integration_tests.rs that assumed fractional() returned String — now it returns serde_json::Value. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
1 parent bc06583 commit 8ae755d

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ temp/
4747
Thumbs.db
4848
ehthumbs.db
4949
Desktop.ini
50+
worktrees/

src/operators/fractional.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,22 @@ mod tests {
386386
} else {
387387
json!("high")
388388
};
389-
assert_eq!(result, expected, "bucket assignment must match the spec formula");
389+
assert_eq!(
390+
result, expected,
391+
"bucket assignment must match the spec formula"
392+
);
390393
}
391394

392395
#[test]
393396
fn test_fractional_boolean_bucket_names() {
394397
// Boolean values are valid bucket names — used when fractional is a condition
395398
let buckets = vec![json!(false), json!(0u64), json!(true), json!(100u64)];
396399
let result = fractional("any-key", &buckets).unwrap();
397-
assert_eq!(result, json!(true), "100% weight on true must always select true");
400+
assert_eq!(
401+
result,
402+
json!(true),
403+
"100% weight on true must always select true"
404+
);
398405
}
399406

400407
#[test]

tests/integration_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,8 +1616,8 @@ fn test_fractional_distribution_uniformity() {
16161616
// 100k sequential keys — dense sample, fast, and tight enough for 10% tolerance.
16171617
for i in 0u64..100_000 {
16181618
let key = format!("{}", i);
1619-
let bucket_str = fractional(&key, &bucket_defs).unwrap();
1620-
let bucket_idx: usize = bucket_str.parse().unwrap();
1619+
let bucket_val = fractional(&key, &bucket_defs).unwrap();
1620+
let bucket_idx: usize = bucket_val.as_str().unwrap().parse().unwrap();
16211621
hits[bucket_idx] += 1;
16221622
}
16231623

@@ -1656,7 +1656,7 @@ fn test_fractional_boundary_hashes_do_not_panic() {
16561656
let result = fractional(key, &buckets);
16571657
assert!(result.is_ok(), "key={key:?} should not error: {:?}", result);
16581658
assert!(
1659-
["a", "b", "c", "d"].contains(&result.unwrap().as_str()),
1659+
["a", "b", "c", "d"].contains(&result.unwrap().as_str().unwrap()),
16601660
"key={key:?} must map to a valid bucket"
16611661
);
16621662
}

0 commit comments

Comments
 (0)