From 9f987d46a3f3c30005c27c9adba4cd93ef9a26ca Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Thu, 5 Nov 2026 18:45:39 +0000 Subject: [PATCH] fix: Make TestData valueForAll return its value when targeting is off Generated-by: termag --- .../Integrations/TestData/FlagBuilder.hs | 1 + test/Spec/Integrations/TestData.hs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/LaunchDarkly/Server/Integrations/TestData/FlagBuilder.hs b/src/LaunchDarkly/Server/Integrations/TestData/FlagBuilder.hs index 3b10009..173aeec 100644 --- a/src/LaunchDarkly/Server/Integrations/TestData/FlagBuilder.hs +++ b/src/LaunchDarkly/Server/Integrations/TestData/FlagBuilder.hs @@ -203,6 +203,7 @@ valueForAll val fb = fb & variations [Aeson.toJSON val] & variationForAll (0 :: VariationIndex) + & offVariation (0 :: VariationIndex) {-# DEPRECATED valueForAllUsers "Use valueForAll instead" #-} diff --git a/test/Spec/Integrations/TestData.hs b/test/Spec/Integrations/TestData.hs index 79e7c82..b24a1cd 100644 --- a/test/Spec/Integrations/TestData.hs +++ b/test/Spec/Integrations/TestData.hs @@ -24,6 +24,7 @@ allTests = , testTargeting , testRules , testValueForAll + , testValueForAllTargetingOff ] testConfig :: DataSourceFactory -> Config @@ -227,3 +228,20 @@ testValueForAll = TestCase $ do assertEqual "todd receives CustomType1" "CustomType1" =<< stringVariation client "flag-key-1" todd "CustomType2" close client + +testValueForAllTargetingOff :: Test +testValueForAllTargetingOff = TestCase $ do + td <- TestData.newTestData + TestData.update td + =<< ( TestData.flag td "flag-key-1" + <&> TestData.valueForAll ("value" :: Text) + <&> TestData.on False + ) + let config = testConfig (TestData.dataSourceFactory td) + user = makeContext "user" "user" + + client <- makeClient config + + assertEqual "user receives value with targeting off" "value" =<< stringVariation client "flag-key-1" user "default" + + close client