Skip to content

Commit 1cd0f2c

Browse files
committed
test: Model value-only overrides as flags served by fallthrough
1 parent 77541a3 commit 1cd0f2c

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎lib/sdk/server/src/test/java/com/launchdarkly/sdk/server/LDClientOverridesTest.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class LDClientOverridesTest extends BaseTest {
5757
private static final LDValue DEFAULT = LDValue.of("default");
5858

5959
private static FeatureFlag valueFlag(String key, String value) {
60-
return flagBuilder(key).version(1).on(false).offVariation(0).variations(LDValue.of(value)).build();
60+
return flagBuilder(key).version(1).on(true).fallthroughVariation(0).variations(LDValue.of(value)).build();
6161
}
6262

6363
private LDConfig.Builder configWith(DataSystemBuilder dataSystem) {
@@ -81,7 +81,7 @@ private LDConfig uninitializedConfig(ComponentConfigurer<OverrideSource> source)
8181
private static void assertOverrideServed(EvaluationDetail<LDValue> detail, String value) {
8282
assertEquals(LDValue.of(value), detail.getValue());
8383
assertEquals(0, detail.getVariationIndex());
84-
assertEquals(EvaluationReason.off().withOverrideAffected(true), detail.getReason());
84+
assertEquals(EvaluationReason.fallthrough().withOverrideAffected(true), detail.getReason());
8585
}
8686

8787
private static void assertNotReady(EvaluationDetail<LDValue> detail) {
@@ -130,7 +130,7 @@ public void overrideTakesPrecedenceOverLaunchDarklyDataAndOtherFlagsAreUnaffecte
130130
assertOverrideServed(client.jsonValueVariationDetail("shared", CONTEXT, DEFAULT), "override-value");
131131
EvaluationDetail<LDValue> plain = client.jsonValueVariationDetail("plain", CONTEXT, DEFAULT);
132132
assertEquals(LDValue.of("plain-value"), plain.getValue());
133-
assertEquals(EvaluationReason.off(), plain.getReason());
133+
assertEquals(EvaluationReason.fallthrough(), plain.getReason());
134134
assertFalse(plain.getReason().isOverrideAffected());
135135

136136
// Removing the override returns the flag to LaunchDarkly data.

‎lib/sdk/server/src/test/java/com/launchdarkly/sdk/server/OverrideSpecVectorsTest.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ static Iterable<Map.Entry<DataKind, KeyedItems<ItemDescriptor>>> collectionsFrom
5959
flagItems.add(new AbstractMap.SimpleEntry<>(key, FEATURES.deserialize(flags.get(key).toJsonString())));
6060
}
6161
for (String key : flagValues.keys()) {
62-
// A value-only entry is a flag that is off and serves the value as its single variation.
63-
LDValue flag = LDValue.buildObject().put("key", key).put("version", 0).put("on", false)
64-
.put("offVariation", 0).put("variations", LDValue.buildArray().add(flagValues.get(key)).build()).build();
62+
// A value-only entry is a flag that is on and serves the value as its single variation by
63+
// fallthrough.
64+
LDValue flag = LDValue.buildObject().put("key", key).put("version", 0).put("on", true)
65+
.put("variations", LDValue.buildArray().add(flagValues.get(key)).build())
66+
.put("fallthrough", LDValue.buildObject().put("variation", 0).build()).build();
6567
flagItems.add(new AbstractMap.SimpleEntry<>(key, FEATURES.deserialize(flag.toJsonString())));
6668
}
6769
List<Map.Entry<String, ItemDescriptor>> segmentItems = new ArrayList<>();

‎lib/sdk/server/src/test/resources/override-vectors/vectors.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"expect": {
3131
"value": "override-value",
3232
"variationIndex": 0,
33-
"reason": { "kind": "OFF", "overrideAffected": true },
33+
"reason": { "kind": "FALLTHROUGH", "overrideAffected": true },
3434
"summaryOverrideAffected": true
3535
}
3636
},
@@ -53,7 +53,7 @@
5353
"expect": {
5454
"value": "override-value",
5555
"variationIndex": 0,
56-
"reason": { "kind": "OFF", "overrideAffected": true },
56+
"reason": { "kind": "FALLTHROUGH", "overrideAffected": true },
5757
"summaryOverrideAffected": true
5858
}
5959
},

0 commit comments

Comments
 (0)