add support for v2 assignment overrides endpoint in fake server#57
Conversation
|
Needs somebody from @Betterment/test_track_core to claim domain review Use the shovel operator to claim, e.g.:
|
| var assignmentMap map[string][]v1Assignment | ||
| err = json.Unmarshal(requestBytes, &assignmentMap) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| assignments = assignmentMap["assignments"] |
There was a problem hiding this comment.
keeping things simple. the request looks like this:
{
"assignments":[
{"split_name": "allocation_selection_refactor_q1_2018_enabled", "variant": "true"},
{"split_name":"add_preferred_muni_bond_locale_selection_to_dr_enabled", "variant":"false"}
]
}so, i'm just unmarshaling that as a map of string to array of v1Assignment and then pulling the value for that one key
|
<< domain LGTM! |
| for _, assignment := range assignments { | ||
| (*storedAssignments)[assignment.SplitName] = assignment.Variant | ||
| } |
There was a problem hiding this comment.
this is the other new bit compared to the previous singular version. before this was a single assignment, now it's a loop ➰
|
nanda? |
|
Approved! 💥 💫 🌟 |
| // v2AssignmentOverrideRequestBody is the JSON input for the V2 assignment override endpoint | ||
| type v2AssignmentOverrideRequestBody struct { | ||
| Assignments []v1Assignment `json:"assignments"` | ||
| } | ||
|
|
There was a problem hiding this comment.
ended up introducing this to help with deserialization
| }) | ||
| } | ||
|
|
||
| func TestPersistAssignmentV2(t *testing.T) { |
There was a problem hiding this comment.
@smudge i snuck a test in here too since i noticed that there was one for the old way
/domain @Betterment/test_track_core
/no-platform
This PR adds support for the newly added v2 assignment override endpoint. Betterment/test_track#145
I removed support for form url encoded POSTs for this new version of the endpoint. I did this partly because it simplified things and partly because I wasn't entirely sure how we'd wanna handle a POST request with a list of objects. I don't think it's all that valuable given the new request body format.