{"action":"closed","number":744,"pull_request":{"url":"https://api.github.com/repos/transcom/mymove/pulls/744","id":198244186,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4MjQ0MTg2","html_url":"https://github.com/transcom/mymove/pull/744","diff_url":"https://github.com/transcom/mymove/pull/744.diff","patch_url":"https://github.com/transcom/mymove/pull/744.patch","issue_url":"https://api.github.com/repos/transcom/mymove/issues/744","number":744,"state":"closed","locked":false,"title":"Refactors test data generation to allow top-down data customization","user":{"login":"stangah","id":5151804,"node_id":"MDQ6VXNlcjUxNTE4MDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/5151804?v=4","gravatar_id":"","url":"https://api.github.com/users/stangah","html_url":"https://github.com/stangah","followers_url":"https://api.github.com/users/stangah/followers","following_url":"https://api.github.com/users/stangah/following{/other_user}","gists_url":"https://api.github.com/users/stangah/gists{/gist_id}","starred_url":"https://api.github.com/users/stangah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stangah/subscriptions","organizations_url":"https://api.github.com/users/stangah/orgs","repos_url":"https://api.github.com/users/stangah/repos","events_url":"https://api.github.com/users/stangah/events{/privacy}","received_events_url":"https://api.github.com/users/stangah/received_events","type":"User","site_admin":false},"body":"## Description\r\n\r\nAs I'm trying to build a data generator for e2e testing, I was trying to see how I could use `testdatagen` to accomplish it. Since we'll need to log in as certain users and visit certain routes that have ID's in them, being able to set the `ID` of an object and have all the IDs I care about in one place in my data generator is a necessity, and `testdatagen` fell short. I needed the ability to have full control over my data, but I didn't want to lose the convenience of having my entire data chain (from ppm to user, for example) built for me in one function call.\r\n\r\nSo, this is my attempt at bridging that gap and generally improving our data generators. I've refactored most of them to be organized as at least a couple of function types:\r\n```go\r\nfunc MakeThing(db, assertions) Thing {\r\n  // Makes a thing, using values in assertions\r\n}\r\n\r\nfunc MakeDefaultThing(db) Thing {\r\n  // Makes a thing with no assertions\r\n  return MakeThing(db, Assertions{})\r\n}\r\n```\r\n\r\n`MakeThing` accepts an `Assertions` struct that makes some assertions about what that data looks like. Maybe it's just an `ID`, or maybe it's all of the fields. `MakeDefaultThing` is for when you don't really care what it looks like, you just need a thing; default values will be used.\r\n\r\nAlso `Assertions` will contain _all_ the assertions for that chain, which means you can do something like:\r\n```go\r\nassertions := Assertions{\r\n  User: models.User{\r\n    ID: \"your ID\",\r\n  },\r\n}\r\nmove := testdatagen.MakeMove(db, assertions)\r\n\r\nmove.Orders.ServiceMember.User.ID == \"your ID\" // true!\r\n```\r\n\r\n## Reviewer Notes\r\n\r\nThe above was accomplished in large part thanks to the [mergo](https://github.com/imdario/mergo) package, which assists in merging two structs of the same type. Take the following example:\r\n```go\r\nperson := Person{\r\n  Name: \"John\",\r\n}\r\n\r\ndefaults := Person{\r\n  Age: 45,\r\n}\r\n\r\n// Merges defaults values onto person, if the matching field in person has a zero-value\r\nmergo.Merge(&person, defaults)\r\n\r\nfmt.Println(person.Name) // John\r\nfmt.Println(person.Age) // 45\r\n```\r\n\r\n## Code Review Verification Steps\r\n\r\n* [ ] All tests pass.\r\n* [ ] Code follows the guidelines for [Logging](https://github.com/transcom/mymove/blob/master/docs/backend.md#logging)\r\n* [ ] The requirements listed in\r\n [Querying the Database Safely](https://github.com/transcom/mymove/blob/master/docs/backend.md#querying-the-database-safely)\r\n have been satisfied.\r\n* [ ] Any migrations/schema changes also update the diagram in docs/schema/dp3.sqs\r\n* [ ] There are no aXe warnings for UI.\r\n* [ ] This works in IE.\r\n* Any new client dependencies (Google Analytics, hosted libraries, CDNs, etc) have been:\r\n  * [ ] Communicated to @willowbl00\r\n  * [ ] Added to the list of [network dependencies](https://github.com/transcom/mymove#client-network-dependencies)\r\n* [ ] Request review from a member of a different team.\r\n* [ ] (TRIAL) Have the Pivotal acceptance criteria been met for this change?\r\n\r\n## References\r\n\r\n* [Pivotal story](tbd) for this change\r\n* [this article](tbd) explains more about the approach used.","created_at":"2018-06-29T08:07:49Z","updated_at":"2018-06-29T19:10:01Z","closed_at":"2018-06-29T19:10:01Z","merged_at":"2018-06-29T19:10:00Z","merge_commit_sha":"1f8dcd2c3de3bbdce80ba5f3be30cadaba7416f6","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jim","id":3331,"node_id":"MDQ6VXNlcjMzMzE=","avatar_url":"https://avatars1.githubusercontent.com/u/3331?v=4","gravatar_id":"","url":"https://api.github.com/users/jim","html_url":"https://github.com/jim","followers_url":"https://api.github.com/users/jim/followers","following_url":"https://api.github.com/users/jim/following{/other_user}","gists_url":"https://api.github.com/users/jim/gists{/gist_id}","starred_url":"https://api.github.com/users/jim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jim/subscriptions","organizations_url":"https://api.github.com/users/jim/orgs","repos_url":"https://api.github.com/users/jim/repos","events_url":"https://api.github.com/users/jim/events{/privacy}","received_events_url":"https://api.github.com/users/jim/received_events","type":"User","site_admin":false},{"login":"akostibas","id":859429,"node_id":"MDQ6VXNlcjg1OTQyOQ==","avatar_url":"https://avatars2.githubusercontent.com/u/859429?v=4","gravatar_id":"","url":"https://api.github.com/users/akostibas","html_url":"https://github.com/akostibas","followers_url":"https://api.github.com/users/akostibas/followers","following_url":"https://api.github.com/users/akostibas/following{/other_user}","gists_url":"https://api.github.com/users/akostibas/gists{/gist_id}","starred_url":"https://api.github.com/users/akostibas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akostibas/subscriptions","organizations_url":"https://api.github.com/users/akostibas/orgs","repos_url":"https://api.github.com/users/akostibas/repos","events_url":"https://api.github.com/users/akostibas/events{/privacy}","received_events_url":"https://api.github.com/users/akostibas/received_events","type":"User","site_admin":false},{"login":"kilbergr","id":7401870,"node_id":"MDQ6VXNlcjc0MDE4NzA=","avatar_url":"https://avatars3.githubusercontent.com/u/7401870?v=4","gravatar_id":"","url":"https://api.github.com/users/kilbergr","html_url":"https://github.com/kilbergr","followers_url":"https://api.github.com/users/kilbergr/followers","following_url":"https://api.github.com/users/kilbergr/following{/other_user}","gists_url":"https://api.github.com/users/kilbergr/gists{/gist_id}","starred_url":"https://api.github.com/users/kilbergr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kilbergr/subscriptions","organizations_url":"https://api.github.com/users/kilbergr/orgs","repos_url":"https://api.github.com/users/kilbergr/repos","events_url":"https://api.github.com/users/kilbergr/events{/privacy}","received_events_url":"https://api.github.com/users/kilbergr/received_events","type":"User","site_admin":false},{"login":"amitch23","id":8170735,"node_id":"MDQ6VXNlcjgxNzA3MzU=","avatar_url":"https://avatars1.githubusercontent.com/u/8170735?v=4","gravatar_id":"","url":"https://api.github.com/users/amitch23","html_url":"https://github.com/amitch23","followers_url":"https://api.github.com/users/amitch23/followers","following_url":"https://api.github.com/users/amitch23/following{/other_user}","gists_url":"https://api.github.com/users/amitch23/gists{/gist_id}","starred_url":"https://api.github.com/users/amitch23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitch23/subscriptions","organizations_url":"https://api.github.com/users/amitch23/orgs","repos_url":"https://api.github.com/users/amitch23/repos","events_url":"https://api.github.com/users/amitch23/events{/privacy}","received_events_url":"https://api.github.com/users/amitch23/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/transcom/mymove/pulls/744/commits","review_comments_url":"https://api.github.com/repos/transcom/mymove/pulls/744/comments","review_comment_url":"https://api.github.com/repos/transcom/mymove/pulls/comments{/number}","comments_url":"https://api.github.com/repos/transcom/mymove/issues/744/comments","statuses_url":"https://api.github.com/repos/transcom/mymove/statuses/e1c51e5ba64b61b4d55a034935fd6d0d1ccd98c5","head":{"label":"transcom:ps-refactor-datagen","ref":"ps-refactor-datagen","sha":"e1c51e5ba64b61b4d55a034935fd6d0d1ccd98c5","user":{"login":"transcom","id":34352343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MzUyMzQz","avatar_url":"https://avatars0.githubusercontent.com/u/34352343?v=4","gravatar_id":"","url":"https://api.github.com/users/transcom","html_url":"https://github.com/transcom","followers_url":"https://api.github.com/users/transcom/followers","following_url":"https://api.github.com/users/transcom/following{/other_user}","gists_url":"https://api.github.com/users/transcom/gists{/gist_id}","starred_url":"https://api.github.com/users/transcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/transcom/subscriptions","organizations_url":"https://api.github.com/users/transcom/orgs","repos_url":"https://api.github.com/users/transcom/repos","events_url":"https://api.github.com/users/transcom/events{/privacy}","received_events_url":"https://api.github.com/users/transcom/received_events","type":"Organization","site_admin":false},"repo":{"id":114694829,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQ2OTQ4Mjk=","name":"mymove","full_name":"transcom/mymove","owner":{"login":"transcom","id":34352343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MzUyMzQz","avatar_url":"https://avatars0.githubusercontent.com/u/34352343?v=4","gravatar_id":"","url":"https://api.github.com/users/transcom","html_url":"https://github.com/transcom","followers_url":"https://api.github.com/users/transcom/followers","following_url":"https://api.github.com/users/transcom/following{/other_user}","gists_url":"https://api.github.com/users/transcom/gists{/gist_id}","starred_url":"https://api.github.com/users/transcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/transcom/subscriptions","organizations_url":"https://api.github.com/users/transcom/orgs","repos_url":"https://api.github.com/users/transcom/repos","events_url":"https://api.github.com/users/transcom/events{/privacy}","received_events_url":"https://api.github.com/users/transcom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/transcom/mymove","description":"Personal Property Prototype","fork":false,"url":"https://api.github.com/repos/transcom/mymove","forks_url":"https://api.github.com/repos/transcom/mymove/forks","keys_url":"https://api.github.com/repos/transcom/mymove/keys{/key_id}","collaborators_url":"https://api.github.com/repos/transcom/mymove/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/transcom/mymove/teams","hooks_url":"https://api.github.com/repos/transcom/mymove/hooks","issue_events_url":"https://api.github.com/repos/transcom/mymove/issues/events{/number}","events_url":"https://api.github.com/repos/transcom/mymove/events","assignees_url":"https://api.github.com/repos/transcom/mymove/assignees{/user}","branches_url":"https://api.github.com/repos/transcom/mymove/branches{/branch}","tags_url":"https://api.github.com/repos/transcom/mymove/tags","blobs_url":"https://api.github.com/repos/transcom/mymove/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/transcom/mymove/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/transcom/mymove/git/refs{/sha}","trees_url":"https://api.github.com/repos/transcom/mymove/git/trees{/sha}","statuses_url":"https://api.github.com/repos/transcom/mymove/statuses/{sha}","languages_url":"https://api.github.com/repos/transcom/mymove/languages","stargazers_url":"https://api.github.com/repos/transcom/mymove/stargazers","contributors_url":"https://api.github.com/repos/transcom/mymove/contributors","subscribers_url":"https://api.github.com/repos/transcom/mymove/subscribers","subscription_url":"https://api.github.com/repos/transcom/mymove/subscription","commits_url":"https://api.github.com/repos/transcom/mymove/commits{/sha}","git_commits_url":"https://api.github.com/repos/transcom/mymove/git/commits{/sha}","comments_url":"https://api.github.com/repos/transcom/mymove/comments{/number}","issue_comment_url":"https://api.github.com/repos/transcom/mymove/issues/comments{/number}","contents_url":"https://api.github.com/repos/transcom/mymove/contents/{+path}","compare_url":"https://api.github.com/repos/transcom/mymove/compare/{base}...{head}","merges_url":"https://api.github.com/repos/transcom/mymove/merges","archive_url":"https://api.github.com/repos/transcom/mymove/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/transcom/mymove/downloads","issues_url":"https://api.github.com/repos/transcom/mymove/issues{/number}","pulls_url":"https://api.github.com/repos/transcom/mymove/pulls{/number}","milestones_url":"https://api.github.com/repos/transcom/mymove/milestones{/number}","notifications_url":"https://api.github.com/repos/transcom/mymove/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/transcom/mymove/labels{/name}","releases_url":"https://api.github.com/repos/transcom/mymove/releases{/id}","deployments_url":"https://api.github.com/repos/transcom/mymove/deployments","created_at":"2017-12-18T22:41:12Z","updated_at":"2018-06-29T18:54:46Z","pushed_at":"2018-06-29T19:10:00Z","git_url":"git://github.com/transcom/mymove.git","ssh_url":"git@github.com:transcom/mymove.git","clone_url":"https://github.com/transcom/mymove.git","svn_url":"https://github.com/transcom/mymove","homepage":null,"size":15968,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":7,"open_issues":9,"watchers":10,"default_branch":"master"}},"base":{"label":"transcom:master","ref":"master","sha":"edef89851142f93475bb904509aef383df57a64a","user":{"login":"transcom","id":34352343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MzUyMzQz","avatar_url":"https://avatars0.githubusercontent.com/u/34352343?v=4","gravatar_id":"","url":"https://api.github.com/users/transcom","html_url":"https://github.com/transcom","followers_url":"https://api.github.com/users/transcom/followers","following_url":"https://api.github.com/users/transcom/following{/other_user}","gists_url":"https://api.github.com/users/transcom/gists{/gist_id}","starred_url":"https://api.github.com/users/transcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/transcom/subscriptions","organizations_url":"https://api.github.com/users/transcom/orgs","repos_url":"https://api.github.com/users/transcom/repos","events_url":"https://api.github.com/users/transcom/events{/privacy}","received_events_url":"https://api.github.com/users/transcom/received_events","type":"Organization","site_admin":false},"repo":{"id":114694829,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQ2OTQ4Mjk=","name":"mymove","full_name":"transcom/mymove","owner":{"login":"transcom","id":34352343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MzUyMzQz","avatar_url":"https://avatars0.githubusercontent.com/u/34352343?v=4","gravatar_id":"","url":"https://api.github.com/users/transcom","html_url":"https://github.com/transcom","followers_url":"https://api.github.com/users/transcom/followers","following_url":"https://api.github.com/users/transcom/following{/other_user}","gists_url":"https://api.github.com/users/transcom/gists{/gist_id}","starred_url":"https://api.github.com/users/transcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/transcom/subscriptions","organizations_url":"https://api.github.com/users/transcom/orgs","repos_url":"https://api.github.com/users/transcom/repos","events_url":"https://api.github.com/users/transcom/events{/privacy}","received_events_url":"https://api.github.com/users/transcom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/transcom/mymove","description":"Personal Property Prototype","fork":false,"url":"https://api.github.com/repos/transcom/mymove","forks_url":"https://api.github.com/repos/transcom/mymove/forks","keys_url":"https://api.github.com/repos/transcom/mymove/keys{/key_id}","collaborators_url":"https://api.github.com/repos/transcom/mymove/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/transcom/mymove/teams","hooks_url":"https://api.github.com/repos/transcom/mymove/hooks","issue_events_url":"https://api.github.com/repos/transcom/mymove/issues/events{/number}","events_url":"https://api.github.com/repos/transcom/mymove/events","assignees_url":"https://api.github.com/repos/transcom/mymove/assignees{/user}","branches_url":"https://api.github.com/repos/transcom/mymove/branches{/branch}","tags_url":"https://api.github.com/repos/transcom/mymove/tags","blobs_url":"https://api.github.com/repos/transcom/mymove/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/transcom/mymove/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/transcom/mymove/git/refs{/sha}","trees_url":"https://api.github.com/repos/transcom/mymove/git/trees{/sha}","statuses_url":"https://api.github.com/repos/transcom/mymove/statuses/{sha}","languages_url":"https://api.github.com/repos/transcom/mymove/languages","stargazers_url":"https://api.github.com/repos/transcom/mymove/stargazers","contributors_url":"https://api.github.com/repos/transcom/mymove/contributors","subscribers_url":"https://api.github.com/repos/transcom/mymove/subscribers","subscription_url":"https://api.github.com/repos/transcom/mymove/subscription","commits_url":"https://api.github.com/repos/transcom/mymove/commits{/sha}","git_commits_url":"https://api.github.com/repos/transcom/mymove/git/commits{/sha}","comments_url":"https://api.github.com/repos/transcom/mymove/comments{/number}","issue_comment_url":"https://api.github.com/repos/transcom/mymove/issues/comments{/number}","contents_url":"https://api.github.com/repos/transcom/mymove/contents/{+path}","compare_url":"https://api.github.com/repos/transcom/mymove/compare/{base}...{head}","merges_url":"https://api.github.com/repos/transcom/mymove/merges","archive_url":"https://api.github.com/repos/transcom/mymove/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/transcom/mymove/downloads","issues_url":"https://api.github.com/repos/transcom/mymove/issues{/number}","pulls_url":"https://api.github.com/repos/transcom/mymove/pulls{/number}","milestones_url":"https://api.github.com/repos/transcom/mymove/milestones{/number}","notifications_url":"https://api.github.com/repos/transcom/mymove/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/transcom/mymove/labels{/name}","releases_url":"https://api.github.com/repos/transcom/mymove/releases{/id}","deployments_url":"https://api.github.com/repos/transcom/mymove/deployments","created_at":"2017-12-18T22:41:12Z","updated_at":"2018-06-29T18:54:46Z","pushed_at":"2018-06-29T19:10:00Z","git_url":"git://github.com/transcom/mymove.git","ssh_url":"git@github.com:transcom/mymove.git","clone_url":"https://github.com/transcom/mymove.git","svn_url":"https://github.com/transcom/mymove","homepage":null,"size":15968,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":7,"open_issues":9,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/transcom/mymove/pulls/744"},"html":{"href":"https://github.com/transcom/mymove/pull/744"},"issue":{"href":"https://api.github.com/repos/transcom/mymove/issues/744"},"comments":{"href":"https://api.github.com/repos/transcom/mymove/issues/744/comments"},"review_comments":{"href":"https://api.github.com/repos/transcom/mymove/pulls/744/comments"},"review_comment":{"href":"https://api.github.com/repos/transcom/mymove/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/transcom/mymove/pulls/744/commits"},"statuses":{"href":"https://api.github.com/repos/transcom/mymove/statuses/e1c51e5ba64b61b4d55a034935fd6d0d1ccd98c5"}},"author_association":"CONTRIBUTOR","merged":true,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":{"login":"stangah","id":5151804,"node_id":"MDQ6VXNlcjUxNTE4MDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/5151804?v=4","gravatar_id":"","url":"https://api.github.com/users/stangah","html_url":"https://github.com/stangah","followers_url":"https://api.github.com/users/stangah/followers","following_url":"https://api.github.com/users/stangah/following{/other_user}","gists_url":"https://api.github.com/users/stangah/gists{/gist_id}","starred_url":"https://api.github.com/users/stangah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stangah/subscriptions","organizations_url":"https://api.github.com/users/stangah/orgs","repos_url":"https://api.github.com/users/stangah/repos","events_url":"https://api.github.com/users/stangah/events{/privacy}","received_events_url":"https://api.github.com/users/stangah/received_events","type":"User","site_admin":false},"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":6,"additions":629,"deletions":443,"changed_files":57}}
{"actor":{"display_login":"stangah"}}