{"action":"created","comment":{"url":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/comments/42410513","id":42410513,"diff_hunk":"@@ -0,0 +1,161 @@\n+package convert\n+\n+import (\n+\t\"testing\"\n+\n+\t\"github.com/stretchr/testify/assert\"\n+\t\"gopkg.in/mgo.v2/bson\"\n+)\n+\n+func TestConvertBsonBytes(t *testing.T) {\n+\tdoc := bson.M{\n+\t\t\"op\": \"i\",\n+\t\t\"ns\": \"throttle.test\",\n+\t\t\"o\": bson.M{\n+\t\t\t\"_id\": bson.NewObjectId(),\n+\t\t\t\"val\": \"55d57fd49e8a1b0d007f73b4\",\n+\t\t},\n+\t}\n+\tbytes, err := bson.Marshal(doc)\n+\tassert.NoError(t, err)\n+\n+\top, err := OplogBytesToOp(bytes)\n+\tassert.NoError(t, err)\n+\tassert.Equal(t, \"insert\", op.Type)\n+}\n+\n+func TestConvertInsertOp(t *testing.T) {\n+\tobj := bson.M{\n+\t\t\"_id\": \"teacherId\",\n+\t\t\"val\": \"55d57fd49e8a1b0d007f73b4\",\n+\t}\n+\tdoc := bson.M{\n+\t\t\"v\":  2,","path":"convert/convert_test.go","position":33,"original_position":33,"commit_id":"5d719f4cd26e5902eeed34d9f7e91cd2c433591b","original_commit_id":"5d719f4cd26e5902eeed34d9f7e91cd2c433591b","user":{"login":"natebrennand","id":2801090,"avatar_url":"https://avatars.githubusercontent.com/u/2801090?v=3","gravatar_id":"","url":"https://api.github.com/users/natebrennand","html_url":"https://github.com/natebrennand","followers_url":"https://api.github.com/users/natebrennand/followers","following_url":"https://api.github.com/users/natebrennand/following{/other_user}","gists_url":"https://api.github.com/users/natebrennand/gists{/gist_id}","starred_url":"https://api.github.com/users/natebrennand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natebrennand/subscriptions","organizations_url":"https://api.github.com/users/natebrennand/orgs","repos_url":"https://api.github.com/users/natebrennand/repos","events_url":"https://api.github.com/users/natebrennand/events{/privacy}","received_events_url":"https://api.github.com/users/natebrennand/received_events","type":"User","site_admin":false},"body":"What is the `\"v\"` key for? It doesn't seem to be referenced anywhere else in the PR's except these test cases","created_at":"2015-10-19T18:49:24Z","updated_at":"2015-10-19T18:49:24Z","html_url":"https://github.com/Clever/mongo-op-throttler/pull/2#discussion_r42410513","pull_request_url":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/comments/42410513"},"html":{"href":"https://github.com/Clever/mongo-op-throttler/pull/2#discussion_r42410513"},"pull_request":{"href":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/2","id":47963243,"html_url":"https://github.com/Clever/mongo-op-throttler/pull/2","diff_url":"https://github.com/Clever/mongo-op-throttler/pull/2.diff","patch_url":"https://github.com/Clever/mongo-op-throttler/pull/2.patch","issue_url":"https://api.github.com/repos/Clever/mongo-op-throttler/issues/2","number":2,"state":"open","locked":false,"title":"Convert oplog to canonical format","user":{"login":"kvigen","id":5514539,"avatar_url":"https://avatars.githubusercontent.com/u/5514539?v=3","gravatar_id":"","url":"https://api.github.com/users/kvigen","html_url":"https://github.com/kvigen","followers_url":"https://api.github.com/users/kvigen/followers","following_url":"https://api.github.com/users/kvigen/following{/other_user}","gists_url":"https://api.github.com/users/kvigen/gists{/gist_id}","starred_url":"https://api.github.com/users/kvigen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvigen/subscriptions","organizations_url":"https://api.github.com/users/kvigen/orgs","repos_url":"https://api.github.com/users/kvigen/repos","events_url":"https://api.github.com/users/kvigen/events{/privacy}","received_events_url":"https://api.github.com/users/kvigen/received_events","type":"User","site_admin":false},"body":"This change converts the oplog into our canonical mongo operation format so that\r\nit's easy to use in the code that actual applies Mongo operations.\r\n\r\nThe code is a bit hairy since oplogs are a bit wonky themselves, but we based the\r\nlogic after the actual code Mongo uses to interpret oplogs, so it should be pretty safe.\r\n\r\nWe'll also do quite a bit of end-to-end testing to make sure we can handle everything.","created_at":"2015-10-16T21:38:28Z","updated_at":"2015-10-19T18:49:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4786fae1c2836cb420f9c14274da4b45b4de92ba","assignee":{"login":"natebrennand","id":2801090,"avatar_url":"https://avatars.githubusercontent.com/u/2801090?v=3","gravatar_id":"","url":"https://api.github.com/users/natebrennand","html_url":"https://github.com/natebrennand","followers_url":"https://api.github.com/users/natebrennand/followers","following_url":"https://api.github.com/users/natebrennand/following{/other_user}","gists_url":"https://api.github.com/users/natebrennand/gists{/gist_id}","starred_url":"https://api.github.com/users/natebrennand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natebrennand/subscriptions","organizations_url":"https://api.github.com/users/natebrennand/orgs","repos_url":"https://api.github.com/users/natebrennand/repos","events_url":"https://api.github.com/users/natebrennand/events{/privacy}","received_events_url":"https://api.github.com/users/natebrennand/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/2/commits","review_comments_url":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/2/comments","review_comment_url":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Clever/mongo-op-throttler/issues/2/comments","statuses_url":"https://api.github.com/repos/Clever/mongo-op-throttler/statuses/5d719f4cd26e5902eeed34d9f7e91cd2c433591b","head":{"label":"Clever:oplog-convert","ref":"oplog-convert","sha":"5d719f4cd26e5902eeed34d9f7e91cd2c433591b","user":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"repo":{"id":43915579,"name":"mongo-op-throttler","full_name":"Clever/mongo-op-throttler","owner":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Clever/mongo-op-throttler","description":"Applies a list of mongo operations at a limited speed. ","fork":false,"url":"https://api.github.com/repos/Clever/mongo-op-throttler","forks_url":"https://api.github.com/repos/Clever/mongo-op-throttler/forks","keys_url":"https://api.github.com/repos/Clever/mongo-op-throttler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Clever/mongo-op-throttler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Clever/mongo-op-throttler/teams","hooks_url":"https://api.github.com/repos/Clever/mongo-op-throttler/hooks","issue_events_url":"https://api.github.com/repos/Clever/mongo-op-throttler/issues/events{/number}","events_url":"https://api.github.com/repos/Clever/mongo-op-throttler/events","assignees_url":"https://api.github.com/repos/Clever/mongo-op-throttler/assignees{/user}","branches_url":"https://api.github.com/repos/Clever/mongo-op-throttler/branches{/branch}","tags_url":"https://api.github.com/repos/Clever/mongo-op-throttler/tags","blobs_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/refs{/sha}","trees_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Clever/mongo-op-throttler/statuses/{sha}","languages_url":"https://api.github.com/repos/Clever/mongo-op-throttler/languages","stargazers_url":"https://api.github.com/repos/Clever/mongo-op-throttler/stargazers","contributors_url":"https://api.github.com/repos/Clever/mongo-op-throttler/contributors","subscribers_url":"https://api.github.com/repos/Clever/mongo-op-throttler/subscribers","subscription_url":"https://api.github.com/repos/Clever/mongo-op-throttler/subscription","commits_url":"https://api.github.com/repos/Clever/mongo-op-throttler/commits{/sha}","git_commits_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/commits{/sha}","comments_url":"https://api.github.com/repos/Clever/mongo-op-throttler/comments{/number}","issue_comment_url":"https://api.github.com/repos/Clever/mongo-op-throttler/issues/comments{/number}","contents_url":"https://api.github.com/repos/Clever/mongo-op-throttler/contents/{+path}","compare_url":"https://api.github.com/repos/Clever/mongo-op-throttler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Clever/mongo-op-throttler/merges","archive_url":"https://api.github.com/repos/Clever/mongo-op-throttler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Clever/mongo-op-throttler/downloads","issues_url":"https://api.github.com/repos/Clever/mongo-op-throttler/issues{/number}","pulls_url":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls{/number}","milestones_url":"https://api.github.com/repos/Clever/mongo-op-throttler/milestones{/number}","notifications_url":"https://api.github.com/repos/Clever/mongo-op-throttler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Clever/mongo-op-throttler/labels{/name}","releases_url":"https://api.github.com/repos/Clever/mongo-op-throttler/releases{/id}","created_at":"2015-10-08T20:50:22Z","updated_at":"2015-10-08T20:52:53Z","pushed_at":"2015-10-16T23:58:51Z","git_url":"git://github.com/Clever/mongo-op-throttler.git","ssh_url":"git@github.com:Clever/mongo-op-throttler.git","clone_url":"https://github.com/Clever/mongo-op-throttler.git","svn_url":"https://github.com/Clever/mongo-op-throttler","homepage":null,"size":151,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"Clever:birthday","ref":"birthday","sha":"9760d1732f92bc683ffcfe6f13c6a623f2ea43ec","user":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"repo":{"id":43915579,"name":"mongo-op-throttler","full_name":"Clever/mongo-op-throttler","owner":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Clever/mongo-op-throttler","description":"Applies a list of mongo operations at a limited speed. ","fork":false,"url":"https://api.github.com/repos/Clever/mongo-op-throttler","forks_url":"https://api.github.com/repos/Clever/mongo-op-throttler/forks","keys_url":"https://api.github.com/repos/Clever/mongo-op-throttler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Clever/mongo-op-throttler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Clever/mongo-op-throttler/teams","hooks_url":"https://api.github.com/repos/Clever/mongo-op-throttler/hooks","issue_events_url":"https://api.github.com/repos/Clever/mongo-op-throttler/issues/events{/number}","events_url":"https://api.github.com/repos/Clever/mongo-op-throttler/events","assignees_url":"https://api.github.com/repos/Clever/mongo-op-throttler/assignees{/user}","branches_url":"https://api.github.com/repos/Clever/mongo-op-throttler/branches{/branch}","tags_url":"https://api.github.com/repos/Clever/mongo-op-throttler/tags","blobs_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/refs{/sha}","trees_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Clever/mongo-op-throttler/statuses/{sha}","languages_url":"https://api.github.com/repos/Clever/mongo-op-throttler/languages","stargazers_url":"https://api.github.com/repos/Clever/mongo-op-throttler/stargazers","contributors_url":"https://api.github.com/repos/Clever/mongo-op-throttler/contributors","subscribers_url":"https://api.github.com/repos/Clever/mongo-op-throttler/subscribers","subscription_url":"https://api.github.com/repos/Clever/mongo-op-throttler/subscription","commits_url":"https://api.github.com/repos/Clever/mongo-op-throttler/commits{/sha}","git_commits_url":"https://api.github.com/repos/Clever/mongo-op-throttler/git/commits{/sha}","comments_url":"https://api.github.com/repos/Clever/mongo-op-throttler/comments{/number}","issue_comment_url":"https://api.github.com/repos/Clever/mongo-op-throttler/issues/comments{/number}","contents_url":"https://api.github.com/repos/Clever/mongo-op-throttler/contents/{+path}","compare_url":"https://api.github.com/repos/Clever/mongo-op-throttler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Clever/mongo-op-throttler/merges","archive_url":"https://api.github.com/repos/Clever/mongo-op-throttler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Clever/mongo-op-throttler/downloads","issues_url":"https://api.github.com/repos/Clever/mongo-op-throttler/issues{/number}","pulls_url":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls{/number}","milestones_url":"https://api.github.com/repos/Clever/mongo-op-throttler/milestones{/number}","notifications_url":"https://api.github.com/repos/Clever/mongo-op-throttler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Clever/mongo-op-throttler/labels{/name}","releases_url":"https://api.github.com/repos/Clever/mongo-op-throttler/releases{/id}","created_at":"2015-10-08T20:50:22Z","updated_at":"2015-10-08T20:52:53Z","pushed_at":"2015-10-16T23:58:51Z","git_url":"git://github.com/Clever/mongo-op-throttler.git","ssh_url":"git@github.com:Clever/mongo-op-throttler.git","clone_url":"https://github.com/Clever/mongo-op-throttler.git","svn_url":"https://github.com/Clever/mongo-op-throttler","homepage":null,"size":151,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/2"},"html":{"href":"https://github.com/Clever/mongo-op-throttler/pull/2"},"issue":{"href":"https://api.github.com/repos/Clever/mongo-op-throttler/issues/2"},"comments":{"href":"https://api.github.com/repos/Clever/mongo-op-throttler/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Clever/mongo-op-throttler/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/Clever/mongo-op-throttler/statuses/5d719f4cd26e5902eeed34d9f7e91cd2c433591b"}}}}