Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test cases for flags with empty string value #108

37 changes: 37 additions & 0 deletions assignment-v2/test-case-7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"experiment": "empty_string_variations_test",
"valueType": "string",
"subjectsWithAttributes": [
{
"subjectKey": "subject-1",
"subjectAttributes": {
"email": "[email protected]"
}
},
{
"subjectKey": "subject-2",
"subjectAttributes": {
"email": "[email protected]"
}
},
{
"subjectKey": "subject-3",
"subjectAttributes": {
"device": "android",
"version": "1.0.0"
}
},
{
"subjectKey": "subject-4",
"subjectAttributes": {
"country": "US"
}
}
],
"expectedAssignments": [
"test-value",
"",
"another-value",
""
]
}
71 changes: 71 additions & 0 deletions ufc/flags-v1-obfuscated.json
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,77 @@
"value": "eyJhIjogIueFp+mhviIsICJiIjogIua8guS6riJ9"
}
}
},
"1d23cbd300895799fda462f81ec4e135": {
"key": "1d23cbd300895799fda462f81ec4e135",
"comment": "Testing the empty string as a variation value",
"enabled": true,
"variationType": "STRING",
"variations": {
"ZW1wdHlfc3RyaW5n": {
"key": "ZW1wdHlfc3RyaW5n",
"value": ""
},
"bm9uX2VtcHR5": {
"key": "bm9uX2VtcHR5",
"value": "bm9uX2VtcHR5"
}
},
"allocations": [
{
"key": "YWxsb2NhdGlvbi1lbXB0eQ==",
"rules": [
{
"conditions": [
{
"attribute": "e909c2d7067ea37437cf97fe11d91bd0",
"operator": "05015086bdd8402218f6aad6528bef08",
"value": "VVM="
}
]
}
],
"splits": [
{
"variationKey": "ZW1wdHlfc3RyaW5n",
"shards": [
{
"salt": "YWxsb2NhdGlvbi1lbXB0eS1zaGFyZHM=",
"ranges": [
{
"start": 0,
"end": 10000
}
]
}
]
}
],
"doLog": true
},
{
"key": "YWxsb2NhdGlvbi10ZXN0",
"rules": [],
"splits": [
{
"variationKey": "bm9uX2VtcHR5",
"shards": [
{
"salt": "YWxsb2NhdGlvbi1lbXB0eS1zaGFyZHM=",
"ranges": [
{
"start": 0,
"end": 10000
}
]
}
]
}
],
"doLog": true
}
],
"totalShards": 10000
}
}
}
71 changes: 71 additions & 0 deletions ufc/flags-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,77 @@
],
"totalShards": 10000
},
"empty_string_flag": {
"key": "empty_string_flag",
"enabled": true,
"comment": "Testing the empty string as a variation value",
"variationType": "STRING",
"variations": {
"empty_string": {
"key": "empty_string",
"value": ""
},
"non_empty": {
"key": "non_empty",
"value": "non_empty"
}
},
"allocations": [
{
"key": "allocation-empty",
"rules": [
{
"conditions": [
{
"attribute": "country",
"operator": "MATCHES",
"value": "US"
}
]
}
],
"splits": [
{
"variationKey": "empty_string",
"shards": [
{
"salt": "allocation-empty-shards",
"ranges": [
{
"start": 0,
"end": 10000
}
]
}
]
}
],
"doLog": true
},
{
"key": "allocation-test",
"rules": [],
"splits": [
{
"variationKey": "non_empty",
"shards": [
{
"salt": "allocation-empty-shards",
"ranges": [
{
"start": 0,
"end": 10000
}
]
}
]
}
],
"doLog": true
}
],
"totalShards": 10000
},
"kill-switch": {
"key": "kill-switch",
"enabled": true,
Expand Down
73 changes: 73 additions & 0 deletions ufc/tests/test-case-flag-with-empty-string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"flag": "empty_string_flag",
"variationType": "STRING",
"defaultValue": "default",
"subjects": [
{
"subjectKey": "alice",
"subjectAttributes": {
"country": "US"
},
"assignment": "",
"evaluationDetails": {
"environmentName": "Test",
"flagEvaluationCode": "MATCH",
"flagEvaluationDescription": "Supplied attributes match rules defined in allocation \"allocation-empty\".",
"banditKey": null,
"banditAction": null,
"variationKey": "empty_string",
"variationValue": "",
"matchedRule": {
"conditions": [
{
"attribute": "country",
"operator": "MATCHES",
"value": "US"
}
]
},
"matchedAllocation": {
"key": "allocation-empty",
"allocationEvaluationCode": "MATCH",
"orderPosition": 1
},
"unmatchedAllocations": [],
"unevaluatedAllocations": [
{
"allocationEvaluationCode": "UNEVALUATED",
"key": "allocation-test",
"orderPosition": 2
}
]
}
},
{
"subjectKey": "bob",
"subjectAttributes": {},
"assignment": "non_empty",
"evaluationDetails": {
"environmentName": "Test",
"flagEvaluationCode": "MATCH",
"flagEvaluationDescription": "bob belongs to the range of traffic assigned to \"non_empty\" defined in allocation \"allocation-test\".",
"banditKey": null,
"banditAction": null,
"variationKey": "non_empty",
"variationValue": "non_empty",
"matchedRule": null,
"matchedAllocation": {
"key": "allocation-test",
"allocationEvaluationCode": "MATCH",
"orderPosition": 2
},
"unmatchedAllocations": [
{
"allocationEvaluationCode": "FAILING_RULE",
"key": "allocation-empty",
"orderPosition": 1
}
],
"unevaluatedAllocations": []
}
}
]
}
Loading