Skip to content

Commit 5178f0b

Browse files
nicklaslclaude
andauthored
test: add spec test for fallthrough with read materialization (#471)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2a955e0 commit 5178f0b

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

confidence-resolver/src/resolver_spec_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ spec_test!(missing_segment_then_match);
622622
spec_test!(null_targeting_key_then_match);
623623
spec_test!(no_assignment_then_match);
624624
spec_test!(fallthrough_with_write_mat);
625+
spec_test!(fallthrough_with_read_mat_should_not_match_as_variant);
625626
spec_test!(fallthrough_then_no_match_should_apply);
626627

627628
// Additional materialization tests

confidence-resolver/test-payloads/resolver-spec/state.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,29 @@
17181718
}
17191719
]
17201720
},
1721+
"flags/fallthrough-read-mat": {
1722+
"name": "flags/fallthrough-read-mat",
1723+
"state": "ACTIVE",
1724+
"clients": ["clients/test-client"],
1725+
"variants": [{ "name": "treatment", "value": { "color": "red" } }],
1726+
"rules": [
1727+
{
1728+
"name": "flags/fallthrough-read-mat/rules/rule1",
1729+
"segment": "segments/country-se",
1730+
"enabled": true,
1731+
"targetingKeySelector": "targeting_key",
1732+
"materializationSpec": { "readMaterialization": "materializations/mat1" },
1733+
"assignmentSpec": { "bucketCount": 1000, "assignments": [{ "assignmentId": "a-ft", "fallthrough": {}, "bucketRanges": [{ "lower": 0, "upper": 1000 }] }] }
1734+
},
1735+
{
1736+
"name": "flags/fallthrough-read-mat/rules/rule2",
1737+
"segment": "segments/country-se",
1738+
"enabled": true,
1739+
"targetingKeySelector": "targeting_key",
1740+
"assignmentSpec": { "bucketCount": 1000, "assignments": [{ "assignmentId": "a-match", "variant": { "variant": "treatment" }, "bucketRanges": [{ "lower": 0, "upper": 1000 }] }] }
1741+
}
1742+
]
1743+
},
17211744
"flags/fallthrough-no-match": {
17221745
"name": "flags/fallthrough-no-match",
17231746
"state": "ACTIVE",

confidence-resolver/test-payloads/resolver-spec/tests.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,6 +2256,30 @@
22562256
}
22572257
}
22582258
},
2259+
{
2260+
"name": "fallthrough_with_read_mat_should_not_match_as_variant",
2261+
"resolveRequest": {
2262+
"flags": ["flags/fallthrough-read-mat"],
2263+
"evaluationContext": { "targeting_key": "user1", "country": "SE" },
2264+
"clientSecret": "test-secret"
2265+
},
2266+
"materializations": {
2267+
"user1": {
2268+
"materializations/mat1": {
2269+
"isUnitInMaterialization": true,
2270+
"ruleToVariant": {
2271+
"flags/fallthrough-read-mat/rules/rule1": ""
2272+
}
2273+
}
2274+
}
2275+
},
2276+
"expectedResult": {
2277+
"general": {
2278+
"resolvedFlags": [{ "flag": "flags/fallthrough-read-mat", "reason": "RESOLVE_REASON_MATCH", "variant": "treatment", "value": { "color": "red" }, "shouldApply": true }],
2279+
"expectError": null
2280+
}
2281+
}
2282+
},
22592283
{
22602284
"name": "set_no_match",
22612285
"resolveRequest": {

0 commit comments

Comments
 (0)