Skip to content

add support for v2 assignment overrides endpoint in fake server#57

Merged
samandmoore merged 3 commits into
masterfrom
sam-v2-assignment-overrides
Nov 13, 2020
Merged

add support for v2 assignment overrides endpoint in fake server#57
samandmoore merged 3 commits into
masterfrom
sam-v2-assignment-overrides

Conversation

@samandmoore
Copy link
Copy Markdown
Member

/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.

@nanda-prbot
Copy link
Copy Markdown

Needs somebody from @Betterment/test_track_core to claim domain review

Use the shovel operator to claim, e.g.:

@myname << domain && platform

HOW TO: Claim a Review

Comment thread fakeserver/routes.go Outdated
Comment on lines +273 to +278
var assignmentMap map[string][]v1Assignment
err = json.Unmarshal(requestBytes, &assignmentMap)
if err != nil {
return err
}
assignments = assignmentMap["assignments"]
Copy link
Copy Markdown
Member Author

@samandmoore samandmoore Nov 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@smudge
Copy link
Copy Markdown
Member

smudge commented Nov 13, 2020

<< domain LGTM!

Comment thread fakeserver/routes.go
Comment on lines +283 to +285
for _, assignment := range assignments {
(*storedAssignments)[assignment.SplitName] = assignment.Variant
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the other new bit compared to the previous singular version. before this was a single assignment, now it's a loop ➰

@samandmoore
Copy link
Copy Markdown
Member Author

nanda?

@nanda-prbot
Copy link
Copy Markdown

Approved! 💥 💫 🌟

@samandmoore samandmoore changed the base branch from sam-convert-to-go-modules to master November 13, 2020 17:53
Comment thread fakeserver/routes.go
Comment on lines +29 to +33
// v2AssignmentOverrideRequestBody is the JSON input for the V2 assignment override endpoint
type v2AssignmentOverrideRequestBody struct {
Assignments []v1Assignment `json:"assignments"`
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ended up introducing this to help with deserialization

Comment thread fakeserver/server_test.go
})
}

func TestPersistAssignmentV2(t *testing.T) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smudge i snuck a test in here too since i noticed that there was one for the old way

@samandmoore samandmoore merged commit fa748f2 into master Nov 13, 2020
@samandmoore samandmoore deleted the sam-v2-assignment-overrides branch November 13, 2020 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants