Skip to content

Commit d46b866

Browse files
MagicMarkatypotter
andauthored
added test cases for flags with empty string value (#108)
* added test cases for flags with empty string value * fixed test data * fixed test data * fixed test data * fixed test data * fixed test data * updated test data * added obfuscated * updated test data * hash the fields I told Marka to base64encode (#111) * fixed typo * Update ufc/tests/test-case-flag-with-empty-string.json Co-authored-by: Tyler Potter <[email protected]> * fixed conditions * fixed expected evaluation details --------- Co-authored-by: Tyler Potter <[email protected]> Co-authored-by: Ty Potter <[email protected]>
1 parent b3a446a commit d46b866

File tree

4 files changed

+252
-0
lines changed

4 files changed

+252
-0
lines changed

assignment-v2/test-case-7.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"experiment": "empty_string_variations_test",
3+
"valueType": "string",
4+
"subjectsWithAttributes": [
5+
{
6+
"subjectKey": "subject-1",
7+
"subjectAttributes": {
8+
"email": "[email protected]"
9+
}
10+
},
11+
{
12+
"subjectKey": "subject-2",
13+
"subjectAttributes": {
14+
"email": "[email protected]"
15+
}
16+
},
17+
{
18+
"subjectKey": "subject-3",
19+
"subjectAttributes": {
20+
"device": "android",
21+
"version": "1.0.0"
22+
}
23+
},
24+
{
25+
"subjectKey": "subject-4",
26+
"subjectAttributes": {
27+
"country": "US"
28+
}
29+
}
30+
],
31+
"expectedAssignments": [
32+
"test-value",
33+
"",
34+
"another-value",
35+
""
36+
]
37+
}

ufc/flags-v1-obfuscated.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,77 @@
12841284
"value": "eyJhIjogIueFp+mhviIsICJiIjogIua8guS6riJ9"
12851285
}
12861286
}
1287+
},
1288+
"1d23cbd300895799fda462f81ec4e135": {
1289+
"key": "1d23cbd300895799fda462f81ec4e135",
1290+
"comment": "Testing the empty string as a variation value",
1291+
"enabled": true,
1292+
"variationType": "STRING",
1293+
"variations": {
1294+
"ZW1wdHlfc3RyaW5n": {
1295+
"key": "ZW1wdHlfc3RyaW5n",
1296+
"value": ""
1297+
},
1298+
"bm9uX2VtcHR5": {
1299+
"key": "bm9uX2VtcHR5",
1300+
"value": "bm9uX2VtcHR5"
1301+
}
1302+
},
1303+
"allocations": [
1304+
{
1305+
"key": "YWxsb2NhdGlvbi1lbXB0eQ==",
1306+
"rules": [
1307+
{
1308+
"conditions": [
1309+
{
1310+
"attribute": "e909c2d7067ea37437cf97fe11d91bd0",
1311+
"operator": "05015086bdd8402218f6aad6528bef08",
1312+
"value": "VVM="
1313+
}
1314+
]
1315+
}
1316+
],
1317+
"splits": [
1318+
{
1319+
"variationKey": "ZW1wdHlfc3RyaW5n",
1320+
"shards": [
1321+
{
1322+
"salt": "YWxsb2NhdGlvbi1lbXB0eS1zaGFyZHM=",
1323+
"ranges": [
1324+
{
1325+
"start": 0,
1326+
"end": 10000
1327+
}
1328+
]
1329+
}
1330+
]
1331+
}
1332+
],
1333+
"doLog": true
1334+
},
1335+
{
1336+
"key": "YWxsb2NhdGlvbi10ZXN0",
1337+
"rules": [],
1338+
"splits": [
1339+
{
1340+
"variationKey": "bm9uX2VtcHR5",
1341+
"shards": [
1342+
{
1343+
"salt": "YWxsb2NhdGlvbi1lbXB0eS1zaGFyZHM=",
1344+
"ranges": [
1345+
{
1346+
"start": 0,
1347+
"end": 10000
1348+
}
1349+
]
1350+
}
1351+
]
1352+
}
1353+
],
1354+
"doLog": true
1355+
}
1356+
],
1357+
"totalShards": 10000
12871358
}
12881359
}
12891360
}

ufc/flags-v1.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,77 @@
410410
],
411411
"totalShards": 10000
412412
},
413+
"empty_string_flag": {
414+
"key": "empty_string_flag",
415+
"enabled": true,
416+
"comment": "Testing the empty string as a variation value",
417+
"variationType": "STRING",
418+
"variations": {
419+
"empty_string": {
420+
"key": "empty_string",
421+
"value": ""
422+
},
423+
"non_empty": {
424+
"key": "non_empty",
425+
"value": "non_empty"
426+
}
427+
},
428+
"allocations": [
429+
{
430+
"key": "allocation-empty",
431+
"rules": [
432+
{
433+
"conditions": [
434+
{
435+
"attribute": "country",
436+
"operator": "MATCHES",
437+
"value": "US"
438+
}
439+
]
440+
}
441+
],
442+
"splits": [
443+
{
444+
"variationKey": "empty_string",
445+
"shards": [
446+
{
447+
"salt": "allocation-empty-shards",
448+
"ranges": [
449+
{
450+
"start": 0,
451+
"end": 10000
452+
}
453+
]
454+
}
455+
]
456+
}
457+
],
458+
"doLog": true
459+
},
460+
{
461+
"key": "allocation-test",
462+
"rules": [],
463+
"splits": [
464+
{
465+
"variationKey": "non_empty",
466+
"shards": [
467+
{
468+
"salt": "allocation-empty-shards",
469+
"ranges": [
470+
{
471+
"start": 0,
472+
"end": 10000
473+
}
474+
]
475+
}
476+
]
477+
}
478+
],
479+
"doLog": true
480+
}
481+
],
482+
"totalShards": 10000
483+
},
413484
"kill-switch": {
414485
"key": "kill-switch",
415486
"enabled": true,
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"flag": "empty_string_flag",
3+
"variationType": "STRING",
4+
"defaultValue": "default",
5+
"subjects": [
6+
{
7+
"subjectKey": "alice",
8+
"subjectAttributes": {
9+
"country": "US"
10+
},
11+
"assignment": "",
12+
"evaluationDetails": {
13+
"environmentName": "Test",
14+
"flagEvaluationCode": "MATCH",
15+
"flagEvaluationDescription": "Supplied attributes match rules defined in allocation \"allocation-empty\".",
16+
"banditKey": null,
17+
"banditAction": null,
18+
"variationKey": "empty_string",
19+
"variationValue": "",
20+
"matchedRule": {
21+
"conditions": [
22+
{
23+
"attribute": "country",
24+
"operator": "MATCHES",
25+
"value": "US"
26+
}
27+
]
28+
},
29+
"matchedAllocation": {
30+
"key": "allocation-empty",
31+
"allocationEvaluationCode": "MATCH",
32+
"orderPosition": 1
33+
},
34+
"unmatchedAllocations": [],
35+
"unevaluatedAllocations": [
36+
{
37+
"allocationEvaluationCode": "UNEVALUATED",
38+
"key": "allocation-test",
39+
"orderPosition": 2
40+
}
41+
]
42+
}
43+
},
44+
{
45+
"subjectKey": "bob",
46+
"subjectAttributes": {},
47+
"assignment": "non_empty",
48+
"evaluationDetails": {
49+
"environmentName": "Test",
50+
"flagEvaluationCode": "MATCH",
51+
"flagEvaluationDescription": "bob belongs to the range of traffic assigned to \"non_empty\" defined in allocation \"allocation-test\".",
52+
"banditKey": null,
53+
"banditAction": null,
54+
"variationKey": "non_empty",
55+
"variationValue": "non_empty",
56+
"matchedRule": null,
57+
"matchedAllocation": {
58+
"key": "allocation-test",
59+
"allocationEvaluationCode": "MATCH",
60+
"orderPosition": 2
61+
},
62+
"unmatchedAllocations": [
63+
{
64+
"allocationEvaluationCode": "FAILING_RULE",
65+
"key": "allocation-empty",
66+
"orderPosition": 1
67+
}
68+
],
69+
"unevaluatedAllocations": []
70+
}
71+
}
72+
]
73+
}

0 commit comments

Comments
 (0)