{"action":"created","comment":{"url":"https://api.github.com/repos/gitevents/core/pulls/comments/49583067","id":49583067,"diff_hunk":"@@ -0,0 +1,294 @@\n+var test = require('tape');\n+var rewire = require('rewire');\n+var sinon = require('sinon');\n+\n+var addTalkToEventFromPayload = rewire('../../lib/talk/add-to-event-from-payload');\n+\n+var configStub = {\n+  paths: {\n+    events: 'events/'\n+  },\n+  schema: {\n+    default_talk_url: 'http://www.example.com/talks/'\n+  }\n+};\n+\n+var payload = {\n+  issue: {\n+    title: 'issue title',\n+    milestone: {\n+      description: 'milestone description',\n+      due_on: '2016-12-30T00:00:00Z'\n+    }\n+  }\n+};\n+\n+var speaker = {\n+  avatar_url: 'http://www.example.com/speaker-avatar/john-doe',\n+  name: 'john doe',\n+  url: 'http://www.example.com/speaker/john-doe'\n+};\n+\n+addTalkToEventFromPayload.__set__('config', configStub);\n+\n+test('talk is added to event with performer', function (t) {\n+  /**\n+   * Setup inputs / outputs\n+   */\n+\n+  // event we want to update\n+  var existingEvent = {\n+    id: 'existing-event-id',\n+    performer: []\n+  };\n+\n+  // file containing event details for the event we want to update\n+  var existingEventFile = {\n+    content: JSON.stringify(existingEvent),\n+    encoding: 'utf8',\n+    sha: 'existing-event-file-sha'\n+  };\n+\n+  /**\n+   * Setup spies\n+   */\n+\n+  var githubStub = sinon.stub();\n+\n+  var getEventFileSpy = sinon.spy(function() {\n+    return new Promise(function(resolve) {\n+      resolve(existingEventFile);\n+    });\n+  });\n+\n+  var updateEventFileSpy = sinon.spy(function() {\n+    return new Promise(function(resolve) {\n+      resolve();\n+    });\n+  });\n+\n+  addTalkToEventFromPayload.__set__('getEventFile', getEventFileSpy);\n+  addTalkToEventFromPayload.__set__('updateEventFile', updateEventFileSpy);\n+\n+  /**\n+   * Make assertions\n+   */\n+\n+  addTalkToEventFromPayload(payload, speaker, githubStub).then(function(result) {\n+    var spyCall = updateEventFileSpy.getCall(0);\n+\n+    t.equal(updateEventFileSpy.calledOnce, true, 'updateEventFile was called');\n+    t.equal(spyCall.args[0], githubStub, 'correct github instance passed as argument to updateEventFile');\n+    t.equal(spyCall.args[1], configStub, 'correct config instance passed as argument to updateEventFile');\n+    t.equal(spyCall.args[2], 'events/milestone description.json', 'correct filename passed as argument to updateEventFile');\n+    t.equal(spyCall.args[3], existingEventFile.sha, 'correct sha passed as argument to updateEventFile');\n+    t.equal(spyCall.args[4], 'ewogICJpZCI6ICJleGlzdGluZy1ldmVudC1pZCIsCiAgInBlcmZvcm1lciI6IFsKICAgIHsKICAgICAgInR5cGUiOiAiUGVyc29uIiwKICAgICAgImltYWdlIjogImh0dHA6Ly93d3cuZXhhbXBsZS5jb20vc3BlYWtlci1hdmF0YXIvam9obi1kb2UiLAogICAgICAibmFtZSI6ICJqb2huIGRvZSIsCiAgICAgICJpZCI6ICIyMDE2MTIzMC1pc3N1ZS10aXRsZSIsCiAgICAgICJzYW1lQXMiOiAiaHR0cDovL3d3dy5leGFtcGxlLmNvbS9zcGVha2VyL2pvaG4tZG9lIiwKICAgICAgInVybCI6ICJodHRwOi8vd3d3LmV4YW1wbGUuY29tL3RhbGtzLzIwMTYxMjMwLWlzc3VlLXRpdGxlLmh0bWwiCiAgICB9CiAgXQp9', 'correct file content passed as argument to updateEventFile');\n+    t.equal(spyCall.args[5], 'Updated event existing-event-id', 'correct message passed as argument to updateEventFile');\n+    t.equal(result.id, existingEvent.id, 'event is returned');\n+    t.equal(result.performer.length, 1, 'event is returned with performer');\n+\n+    t.end();\n+  });\n+});\n+\n+test.skip('talk is added to event with performer added to existing performers', function (t) {\n+  /**\n+   * Setup inputs / outputs\n+   */\n+\n+  // event we want to update\n+  var existingEvent = {\n+    id: 'existing-event-id',\n+    performer: [\n+      { id: 'performer-1' }\n+    ]\n+  };\n+\n+  // file containing event details for the event we want to update\n+  var existingEventFile = {\n+    content: JSON.stringify(existingEvent),\n+    encoding: 'utf8',\n+    sha: 'existing-event-file-sha'\n+  };\n+\n+  /**\n+   * Setup spies\n+   */\n+\n+  var githubStub = sinon.stub();\n+\n+  var getEventFileSpy = sinon.spy(function() {\n+    return new Promise(function(resolve) {\n+      resolve(existingEventFile);\n+    });\n+  });\n+\n+  var updateEventFileSpy = sinon.spy(function() {\n+    return new Promise(function(resolve) {","path":"tests/talk/add-to-event-from-payload.js","position":127,"original_position":127,"commit_id":"b43e4bc3b4b4b6c7cd5e21c6196260332bf1859f","original_commit_id":"b43e4bc3b4b4b6c7cd5e21c6196260332bf1859f","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"'Promise' is not defined.","created_at":"2016-01-13T12:15:06Z","updated_at":"2016-01-13T12:15:06Z","html_url":"https://github.com/gitevents/core/pull/152#discussion_r49583067","pull_request_url":"https://api.github.com/repos/gitevents/core/pulls/152","_links":{"self":{"href":"https://api.github.com/repos/gitevents/core/pulls/comments/49583067"},"html":{"href":"https://github.com/gitevents/core/pull/152#discussion_r49583067"},"pull_request":{"href":"https://api.github.com/repos/gitevents/core/pulls/152"}}},"pull_request":{"url":"https://api.github.com/repos/gitevents/core/pulls/152","id":55889713,"html_url":"https://github.com/gitevents/core/pull/152","diff_url":"https://github.com/gitevents/core/pull/152.diff","patch_url":"https://github.com/gitevents/core/pull/152.patch","issue_url":"https://api.github.com/repos/gitevents/core/issues/152","number":152,"state":"open","locked":false,"title":"[WIP] Split up events module","user":{"login":"mike182uk","id":991592,"avatar_url":"https://avatars.githubusercontent.com/u/991592?v=3","gravatar_id":"","url":"https://api.github.com/users/mike182uk","html_url":"https://github.com/mike182uk","followers_url":"https://api.github.com/users/mike182uk/followers","following_url":"https://api.github.com/users/mike182uk/following{/other_user}","gists_url":"https://api.github.com/users/mike182uk/gists{/gist_id}","starred_url":"https://api.github.com/users/mike182uk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mike182uk/subscriptions","organizations_url":"https://api.github.com/users/mike182uk/orgs","repos_url":"https://api.github.com/users/mike182uk/repos","events_url":"https://api.github.com/users/mike182uk/events{/privacy}","received_events_url":"https://api.github.com/users/mike182uk/received_events","type":"User","site_admin":false},"body":"In this PR i have attempted to split up the events module, and have added tests to the newly created modules. \r\n\r\nThe intention is to eventually have the whole module covered by tests (by splitting the code into more manageable chunks that are covered by tests).\r\n\r\nI have tried to limit refactoring as much as possible outside of splitting the code up.","created_at":"2016-01-13T12:14:46Z","updated_at":"2016-01-13T12:15:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gitevents/core/pulls/152/commits","review_comments_url":"https://api.github.com/repos/gitevents/core/pulls/152/comments","review_comment_url":"https://api.github.com/repos/gitevents/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gitevents/core/issues/152/comments","statuses_url":"https://api.github.com/repos/gitevents/core/statuses/b43e4bc3b4b4b6c7cd5e21c6196260332bf1859f","head":{"label":"gitevents:refactor-events","ref":"refactor-events","sha":"b43e4bc3b4b4b6c7cd5e21c6196260332bf1859f","user":{"login":"gitevents","id":10575431,"avatar_url":"https://avatars.githubusercontent.com/u/10575431?v=3","gravatar_id":"","url":"https://api.github.com/users/gitevents","html_url":"https://github.com/gitevents","followers_url":"https://api.github.com/users/gitevents/followers","following_url":"https://api.github.com/users/gitevents/following{/other_user}","gists_url":"https://api.github.com/users/gitevents/gists{/gist_id}","starred_url":"https://api.github.com/users/gitevents/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitevents/subscriptions","organizations_url":"https://api.github.com/users/gitevents/orgs","repos_url":"https://api.github.com/users/gitevents/repos","events_url":"https://api.github.com/users/gitevents/events{/privacy}","received_events_url":"https://api.github.com/users/gitevents/received_events","type":"Organization","site_admin":false},"repo":{"id":27631666,"name":"core","full_name":"gitevents/core","owner":{"login":"gitevents","id":10575431,"avatar_url":"https://avatars.githubusercontent.com/u/10575431?v=3","gravatar_id":"","url":"https://api.github.com/users/gitevents","html_url":"https://github.com/gitevents","followers_url":"https://api.github.com/users/gitevents/followers","following_url":"https://api.github.com/users/gitevents/following{/other_user}","gists_url":"https://api.github.com/users/gitevents/gists{/gist_id}","starred_url":"https://api.github.com/users/gitevents/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitevents/subscriptions","organizations_url":"https://api.github.com/users/gitevents/orgs","repos_url":"https://api.github.com/users/gitevents/repos","events_url":"https://api.github.com/users/gitevents/events{/privacy}","received_events_url":"https://api.github.com/users/gitevents/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gitevents/core","description":"GitEvents core; manage your user group with GitHub","fork":false,"url":"https://api.github.com/repos/gitevents/core","forks_url":"https://api.github.com/repos/gitevents/core/forks","keys_url":"https://api.github.com/repos/gitevents/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gitevents/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gitevents/core/teams","hooks_url":"https://api.github.com/repos/gitevents/core/hooks","issue_events_url":"https://api.github.com/repos/gitevents/core/issues/events{/number}","events_url":"https://api.github.com/repos/gitevents/core/events","assignees_url":"https://api.github.com/repos/gitevents/core/assignees{/user}","branches_url":"https://api.github.com/repos/gitevents/core/branches{/branch}","tags_url":"https://api.github.com/repos/gitevents/core/tags","blobs_url":"https://api.github.com/repos/gitevents/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gitevents/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gitevents/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/gitevents/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gitevents/core/statuses/{sha}","languages_url":"https://api.github.com/repos/gitevents/core/languages","stargazers_url":"https://api.github.com/repos/gitevents/core/stargazers","contributors_url":"https://api.github.com/repos/gitevents/core/contributors","subscribers_url":"https://api.github.com/repos/gitevents/core/subscribers","subscription_url":"https://api.github.com/repos/gitevents/core/subscription","commits_url":"https://api.github.com/repos/gitevents/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/gitevents/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/gitevents/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/gitevents/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/gitevents/core/contents/{+path}","compare_url":"https://api.github.com/repos/gitevents/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gitevents/core/merges","archive_url":"https://api.github.com/repos/gitevents/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gitevents/core/downloads","issues_url":"https://api.github.com/repos/gitevents/core/issues{/number}","pulls_url":"https://api.github.com/repos/gitevents/core/pulls{/number}","milestones_url":"https://api.github.com/repos/gitevents/core/milestones{/number}","notifications_url":"https://api.github.com/repos/gitevents/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gitevents/core/labels{/name}","releases_url":"https://api.github.com/repos/gitevents/core/releases{/id}","created_at":"2014-12-06T11:11:18Z","updated_at":"2016-01-12T21:17:42Z","pushed_at":"2016-01-13T12:14:46Z","git_url":"git://github.com/gitevents/core.git","ssh_url":"git@github.com:gitevents/core.git","clone_url":"https://github.com/gitevents/core.git","svn_url":"https://github.com/gitevents/core","homepage":"","size":439,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":25,"forks":18,"open_issues":25,"watchers":28,"default_branch":"master"}},"base":{"label":"gitevents:master","ref":"master","sha":"94604786eb2b2044c513ac9e5d64c955eb04cad5","user":{"login":"gitevents","id":10575431,"avatar_url":"https://avatars.githubusercontent.com/u/10575431?v=3","gravatar_id":"","url":"https://api.github.com/users/gitevents","html_url":"https://github.com/gitevents","followers_url":"https://api.github.com/users/gitevents/followers","following_url":"https://api.github.com/users/gitevents/following{/other_user}","gists_url":"https://api.github.com/users/gitevents/gists{/gist_id}","starred_url":"https://api.github.com/users/gitevents/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitevents/subscriptions","organizations_url":"https://api.github.com/users/gitevents/orgs","repos_url":"https://api.github.com/users/gitevents/repos","events_url":"https://api.github.com/users/gitevents/events{/privacy}","received_events_url":"https://api.github.com/users/gitevents/received_events","type":"Organization","site_admin":false},"repo":{"id":27631666,"name":"core","full_name":"gitevents/core","owner":{"login":"gitevents","id":10575431,"avatar_url":"https://avatars.githubusercontent.com/u/10575431?v=3","gravatar_id":"","url":"https://api.github.com/users/gitevents","html_url":"https://github.com/gitevents","followers_url":"https://api.github.com/users/gitevents/followers","following_url":"https://api.github.com/users/gitevents/following{/other_user}","gists_url":"https://api.github.com/users/gitevents/gists{/gist_id}","starred_url":"https://api.github.com/users/gitevents/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitevents/subscriptions","organizations_url":"https://api.github.com/users/gitevents/orgs","repos_url":"https://api.github.com/users/gitevents/repos","events_url":"https://api.github.com/users/gitevents/events{/privacy}","received_events_url":"https://api.github.com/users/gitevents/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gitevents/core","description":"GitEvents core; manage your user group with GitHub","fork":false,"url":"https://api.github.com/repos/gitevents/core","forks_url":"https://api.github.com/repos/gitevents/core/forks","keys_url":"https://api.github.com/repos/gitevents/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gitevents/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gitevents/core/teams","hooks_url":"https://api.github.com/repos/gitevents/core/hooks","issue_events_url":"https://api.github.com/repos/gitevents/core/issues/events{/number}","events_url":"https://api.github.com/repos/gitevents/core/events","assignees_url":"https://api.github.com/repos/gitevents/core/assignees{/user}","branches_url":"https://api.github.com/repos/gitevents/core/branches{/branch}","tags_url":"https://api.github.com/repos/gitevents/core/tags","blobs_url":"https://api.github.com/repos/gitevents/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gitevents/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gitevents/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/gitevents/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gitevents/core/statuses/{sha}","languages_url":"https://api.github.com/repos/gitevents/core/languages","stargazers_url":"https://api.github.com/repos/gitevents/core/stargazers","contributors_url":"https://api.github.com/repos/gitevents/core/contributors","subscribers_url":"https://api.github.com/repos/gitevents/core/subscribers","subscription_url":"https://api.github.com/repos/gitevents/core/subscription","commits_url":"https://api.github.com/repos/gitevents/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/gitevents/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/gitevents/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/gitevents/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/gitevents/core/contents/{+path}","compare_url":"https://api.github.com/repos/gitevents/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gitevents/core/merges","archive_url":"https://api.github.com/repos/gitevents/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gitevents/core/downloads","issues_url":"https://api.github.com/repos/gitevents/core/issues{/number}","pulls_url":"https://api.github.com/repos/gitevents/core/pulls{/number}","milestones_url":"https://api.github.com/repos/gitevents/core/milestones{/number}","notifications_url":"https://api.github.com/repos/gitevents/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gitevents/core/labels{/name}","releases_url":"https://api.github.com/repos/gitevents/core/releases{/id}","created_at":"2014-12-06T11:11:18Z","updated_at":"2016-01-12T21:17:42Z","pushed_at":"2016-01-13T12:14:46Z","git_url":"git://github.com/gitevents/core.git","ssh_url":"git@github.com:gitevents/core.git","clone_url":"https://github.com/gitevents/core.git","svn_url":"https://github.com/gitevents/core","homepage":"","size":439,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":25,"forks":18,"open_issues":25,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gitevents/core/pulls/152"},"html":{"href":"https://github.com/gitevents/core/pull/152"},"issue":{"href":"https://api.github.com/repos/gitevents/core/issues/152"},"comments":{"href":"https://api.github.com/repos/gitevents/core/issues/152/comments"},"review_comments":{"href":"https://api.github.com/repos/gitevents/core/pulls/152/comments"},"review_comment":{"href":"https://api.github.com/repos/gitevents/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gitevents/core/pulls/152/commits"},"statuses":{"href":"https://api.github.com/repos/gitevents/core/statuses/b43e4bc3b4b4b6c7cd5e21c6196260332bf1859f"}}}}