@@ -98,8 +98,8 @@ func TestValidateVariationDeletion(t *testing.T) {
9898 localizer := locale .NewLocalizer (ctx )
9999
100100 variationID1 := "variation-1"
101+ variationID2 := "variation-2"
101102 variationValue1 := "true"
102- variationValue2 := "false"
103103
104104 patterns := []struct {
105105 desc string
@@ -158,7 +158,16 @@ func TestValidateVariationDeletion(t *testing.T) {
158158 },
159159 features : []* featureproto.Feature {
160160 {
161- Id : "feature-2" ,
161+ Id : "feature-1" , // Target feature (must be included)
162+ Variations : []* featureproto.Variation {
163+ {
164+ Id : variationID1 ,
165+ Value : variationValue1 ,
166+ },
167+ },
168+ },
169+ {
170+ Id : "feature-2" , // Dependent feature
162171 Prerequisites : []* featureproto.Prerequisite {
163172 {
164173 FeatureId : "feature-1" ,
@@ -172,7 +181,7 @@ func TestValidateVariationDeletion(t *testing.T) {
172181 localizer .MustLocalizeWithTemplate (locale .InvalidArgumentError , "variation" ), localizer ),
173182 },
174183 {
175- desc : "error: other feature has FEATURE_FLAG rule using deleted variation value " ,
184+ desc : "error: other feature has FEATURE_FLAG rule using deleted variation ID " ,
176185 variationChanges : []* featureproto.VariationChange {
177186 {
178187 ChangeType : featureproto .ChangeType_DELETE ,
@@ -184,14 +193,23 @@ func TestValidateVariationDeletion(t *testing.T) {
184193 },
185194 features : []* featureproto.Feature {
186195 {
187- Id : "feature-2" ,
196+ Id : "feature-1" , // Target feature (must be included)
197+ Variations : []* featureproto.Variation {
198+ {
199+ Id : variationID1 ,
200+ Value : variationValue1 ,
201+ },
202+ },
203+ },
204+ {
205+ Id : "feature-2" , // Dependent feature
188206 Rules : []* featureproto.Rule {
189207 {
190208 Clauses : []* featureproto.Clause {
191209 {
192210 Operator : featureproto .Clause_FEATURE_FLAG ,
193211 Attribute : "feature-1" ,
194- Values : []string {variationValue1 },
212+ Values : []string {variationID1 }, // Fixed: Use variation ID, not value
195213 },
196214 },
197215 },
@@ -228,7 +246,7 @@ func TestValidateVariationDeletion(t *testing.T) {
228246 expected : nil ,
229247 },
230248 {
231- desc : "success: different variation value in FEATURE_FLAG rule" ,
249+ desc : "success: different variation ID in FEATURE_FLAG rule" ,
232250 variationChanges : []* featureproto.VariationChange {
233251 {
234252 ChangeType : featureproto .ChangeType_DELETE ,
@@ -247,7 +265,7 @@ func TestValidateVariationDeletion(t *testing.T) {
247265 {
248266 Operator : featureproto .Clause_FEATURE_FLAG ,
249267 Attribute : "feature-1" ,
250- Values : []string {variationValue2 }, // Different value
268+ Values : []string {variationID2 }, // Fixed: Different variation ID
251269 },
252270 },
253271 },
0 commit comments