{"action":"created","comment":{"url":"https://api.github.com/repos/alexellis/derek/pulls/comments/172062155","pull_request_review_id":101017462,"id":172062155,"diff_hunk":"@@ -242,3 +244,156 @@ func Test_assessState(t *testing.T) {\n \t\t})\n \t}\n }\n+\n+func Test_validAction(t *testing.T) {\n+\n+\tvar stateOptions = []struct {\n+\t\ttitle           string\n+\t\trunning         bool\n+\t\trequestedAction string\n+\t\tstart           string\n+\t\tstop            string\n+\t\texpectedBool    bool\n+\t}{\n+\t\t{\n+\t\t\ttitle:           \"Currently unlocked and trying to lock\",\n+\t\t\trunning:         false,\n+\t\t\trequestedAction: lockConstant,\n+\t\t\tstart:           lockConstant,\n+\t\t\tstop:            unlockConstant,\n+\t\t\texpectedBool:    true,\n+\t\t},\n+\t\t{\n+\t\t\ttitle:           \"Currently unlocked and trying to unlock\",\n+\t\t\trunning:         false,\n+\t\t\trequestedAction: unlockConstant,\n+\t\t\tstart:           lockConstant,\n+\t\t\tstop:            unlockConstant,\n+\t\t\texpectedBool:    false,\n+\t\t},\n+\t\t{\n+\t\t\ttitle:           \"Currently locked and trying to lock\",\n+\t\t\trunning:         true,\n+\t\t\trequestedAction: lockConstant,\n+\t\t\tstart:           lockConstant,\n+\t\t\tstop:            unlockConstant,\n+\t\t\texpectedBool:    false,\n+\t\t},\n+\t\t{\n+\t\t\ttitle:           \"Currently locked and trying to unlock\",\n+\t\t\trunning:         true,\n+\t\t\trequestedAction: unlockConstant,\n+\t\t\tstart:           lockConstant,\n+\t\t\tstop:            unlockConstant,\n+\t\t\texpectedBool:    true,\n+\t\t},\n+\t}\n+\n+\tfor _, test := range stateOptions {\n+\t\tt.Run(test.title, func(t *testing.T) {\n+\n+\t\t\tisValid := validAction(test.running, test.requestedAction, test.start, test.stop)\n+\n+\t\t\tif isValid != test.expectedBool {\n+\t\t\t\tt.Errorf(\"\\nActions - wanted: %t, got %t\\n\", test.expectedBool, isValid)\n+\t\t\t}\n+\t\t})\n+\t}\n+}\n+\n+func Test_findLabel(t *testing.T) {\n+\n+\tvar stateOptions = []struct {\n+\t\ttitle         string\n+\t\tcurrentLabels []types.IssueLabel\n+\t\tcmdLabel      string\n+\t\texpectedFound bool\n+\t}{\n+\t\t{\n+\t\t\ttitle: \"Label exists lowercase\",\n+\t\t\tcurrentLabels: []types.IssueLabel{\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"rod\",\n+\t\t\t\t},\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"jane\",\n+\t\t\t\t},\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"freddie\",\n+\t\t\t\t},\n+\t\t\t},\n+\t\t\tcmdLabel:      \"rod\",\n+\t\t\texpectedFound: true,\n+\t\t},\n+\t\t{\n+\t\t\ttitle: \"Label exists case insensitive\",\n+\t\t\tcurrentLabels: []types.IssueLabel{\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"rod\",\n+\t\t\t\t},\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"jane\",\n+\t\t\t\t},\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"freddie\",\n+\t\t\t\t},\n+\t\t\t},\n+\t\t\tcmdLabel:      \"Rod\",\n+\t\t\texpectedFound: true,\n+\t\t},\n+\t\t{\n+\t\t\ttitle: \"Label doesnt exist lowercase\",\n+\t\t\tcurrentLabels: []types.IssueLabel{\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"rod\",\n+\t\t\t\t},\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"jane\",\n+\t\t\t\t},\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"freddie\",\n+\t\t\t\t},\n+\t\t\t},\n+\t\t\tcmdLabel:      \"derek\",\n+\t\t\texpectedFound: false,\n+\t\t},\n+\t\t{\n+\t\t\ttitle: \"Label doesnt exist case insensitive\",\n+\t\t\tcurrentLabels: []types.IssueLabel{\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"rod\",\n+\t\t\t\t},\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"jane\",\n+\t\t\t\t},\n+\t\t\t\ttypes.IssueLabel{\n+\t\t\t\t\tName: \"freddie\",\n+\t\t\t\t},\n+\t\t\t},\n+\t\t\tcmdLabel:      \"Derek\",\n+\t\t\texpectedFound: false,\n+\t\t},\n+\t\t{\n+\t\t\ttitle:         \"no existing labels lowercase\",\n+\t\t\tcurrentLabels: nil,\n+\t\t\tcmdLabel:      \"derek\",\n+\t\t\texpectedFound: false,\n+\t\t},\n+\t\t{title: \"Label doesnt exist case insensitive\",\n+\t\t\tcurrentLabels: nil,\n+\t\t\tcmdLabel:      \"Derek\",\n+\t\t\texpectedFound: false,\n+\t\t},\n+\t}\n+\n+\tfor _, test := range stateOptions {\n+\t\tt.Run(test.title, func(t *testing.T) {","path":"commentHandler_test.go","position":148,"original_position":245,"commit_id":"e51bb8a412f4e376daca25bc507cedbdade39b89","original_commit_id":"e51bb8a412f4e376daca25bc507cedbdade39b89","user":{"login":"alexellis","id":6358735,"avatar_url":"https://avatars1.githubusercontent.com/u/6358735?v=4","gravatar_id":"","url":"https://api.github.com/users/alexellis","html_url":"https://github.com/alexellis","followers_url":"https://api.github.com/users/alexellis/followers","following_url":"https://api.github.com/users/alexellis/following{/other_user}","gists_url":"https://api.github.com/users/alexellis/gists{/gist_id}","starred_url":"https://api.github.com/users/alexellis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexellis/subscriptions","organizations_url":"https://api.github.com/users/alexellis/orgs","repos_url":"https://api.github.com/users/alexellis/repos","events_url":"https://api.github.com/users/alexellis/events{/privacy}","received_events_url":"https://api.github.com/users/alexellis/received_events","type":"User","site_admin":false},"body":"Are we using sub-tests elsewhere in the project?","created_at":"2018-03-04T20:00:24Z","updated_at":"2018-03-04T20:00:24Z","html_url":"https://github.com/alexellis/derek/pull/34#discussion_r172062155","pull_request_url":"https://api.github.com/repos/alexellis/derek/pulls/34","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/alexellis/derek/pulls/comments/172062155"},"html":{"href":"https://github.com/alexellis/derek/pull/34#discussion_r172062155"},"pull_request":{"href":"https://api.github.com/repos/alexellis/derek/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/alexellis/derek/pulls/34","id":164948460,"html_url":"https://github.com/alexellis/derek/pull/34","diff_url":"https://github.com/alexellis/derek/pull/34.diff","patch_url":"https://github.com/alexellis/derek/pull/34.patch","issue_url":"https://api.github.com/repos/alexellis/derek/issues/34","number":34,"state":"open","locked":false,"title":"Moved out handleComment code into separate functions.  Added edit title.","user":{"login":"rgee0","id":16418793,"avatar_url":"https://avatars2.githubusercontent.com/u/16418793?v=4","gravatar_id":"","url":"https://api.github.com/users/rgee0","html_url":"https://github.com/rgee0","followers_url":"https://api.github.com/users/rgee0/followers","following_url":"https://api.github.com/users/rgee0/following{/other_user}","gists_url":"https://api.github.com/users/rgee0/gists{/gist_id}","starred_url":"https://api.github.com/users/rgee0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgee0/subscriptions","organizations_url":"https://api.github.com/users/rgee0/orgs","repos_url":"https://api.github.com/users/rgee0/repos","events_url":"https://api.github.com/users/rgee0/events{/privacy}","received_events_url":"https://api.github.com/users/rgee0/received_events","type":"User","site_admin":false},"body":"Summary of changes:\r\n\r\nMoved out handleComment code into separate functions.  \r\nAdded tests for new helper functions.  \r\nAdded edit title as an alias for set title\r\nUpdated README\r\nFactored out log.Fatal\r\nAltered main.go such that a http 500 is not longer seen when an unexpected X_Github_Event is received\r\nExtracted constants to provide consistency between values used in parse and handleComment.\r\n\r\nSigned-off-by: rgee0 <richard@technologee.co.uk>\r\n\r\n\r\nA test instance is running over on https://github.com/rgee0/Test.  This is hosted so should be always on","created_at":"2018-01-24T20:02:06Z","updated_at":"2018-03-04T20:00:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0091a1d77e43e2b6f4341872231d2fb62460fae9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/alexellis/derek/pulls/34/commits","review_comments_url":"https://api.github.com/repos/alexellis/derek/pulls/34/comments","review_comment_url":"https://api.github.com/repos/alexellis/derek/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alexellis/derek/issues/34/comments","statuses_url":"https://api.github.com/repos/alexellis/derek/statuses/e51bb8a412f4e376daca25bc507cedbdade39b89","head":{"label":"rgee0:functionsAndEditTitle","ref":"functionsAndEditTitle","sha":"e51bb8a412f4e376daca25bc507cedbdade39b89","user":{"login":"rgee0","id":16418793,"avatar_url":"https://avatars2.githubusercontent.com/u/16418793?v=4","gravatar_id":"","url":"https://api.github.com/users/rgee0","html_url":"https://github.com/rgee0","followers_url":"https://api.github.com/users/rgee0/followers","following_url":"https://api.github.com/users/rgee0/following{/other_user}","gists_url":"https://api.github.com/users/rgee0/gists{/gist_id}","starred_url":"https://api.github.com/users/rgee0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgee0/subscriptions","organizations_url":"https://api.github.com/users/rgee0/orgs","repos_url":"https://api.github.com/users/rgee0/repos","events_url":"https://api.github.com/users/rgee0/events{/privacy}","received_events_url":"https://api.github.com/users/rgee0/received_events","type":"User","site_admin":false},"repo":{"id":108023574,"name":"derek","full_name":"rgee0/derek","owner":{"login":"rgee0","id":16418793,"avatar_url":"https://avatars2.githubusercontent.com/u/16418793?v=4","gravatar_id":"","url":"https://api.github.com/users/rgee0","html_url":"https://github.com/rgee0","followers_url":"https://api.github.com/users/rgee0/followers","following_url":"https://api.github.com/users/rgee0/following{/other_user}","gists_url":"https://api.github.com/users/rgee0/gists{/gist_id}","starred_url":"https://api.github.com/users/rgee0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgee0/subscriptions","organizations_url":"https://api.github.com/users/rgee0/orgs","repos_url":"https://api.github.com/users/rgee0/repos","events_url":"https://api.github.com/users/rgee0/events{/privacy}","received_events_url":"https://api.github.com/users/rgee0/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rgee0/derek","description":"derek - a serverless :robot: to manage PRs and issues","fork":true,"url":"https://api.github.com/repos/rgee0/derek","forks_url":"https://api.github.com/repos/rgee0/derek/forks","keys_url":"https://api.github.com/repos/rgee0/derek/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rgee0/derek/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rgee0/derek/teams","hooks_url":"https://api.github.com/repos/rgee0/derek/hooks","issue_events_url":"https://api.github.com/repos/rgee0/derek/issues/events{/number}","events_url":"https://api.github.com/repos/rgee0/derek/events","assignees_url":"https://api.github.com/repos/rgee0/derek/assignees{/user}","branches_url":"https://api.github.com/repos/rgee0/derek/branches{/branch}","tags_url":"https://api.github.com/repos/rgee0/derek/tags","blobs_url":"https://api.github.com/repos/rgee0/derek/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rgee0/derek/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rgee0/derek/git/refs{/sha}","trees_url":"https://api.github.com/repos/rgee0/derek/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rgee0/derek/statuses/{sha}","languages_url":"https://api.github.com/repos/rgee0/derek/languages","stargazers_url":"https://api.github.com/repos/rgee0/derek/stargazers","contributors_url":"https://api.github.com/repos/rgee0/derek/contributors","subscribers_url":"https://api.github.com/repos/rgee0/derek/subscribers","subscription_url":"https://api.github.com/repos/rgee0/derek/subscription","commits_url":"https://api.github.com/repos/rgee0/derek/commits{/sha}","git_commits_url":"https://api.github.com/repos/rgee0/derek/git/commits{/sha}","comments_url":"https://api.github.com/repos/rgee0/derek/comments{/number}","issue_comment_url":"https://api.github.com/repos/rgee0/derek/issues/comments{/number}","contents_url":"https://api.github.com/repos/rgee0/derek/contents/{+path}","compare_url":"https://api.github.com/repos/rgee0/derek/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rgee0/derek/merges","archive_url":"https://api.github.com/repos/rgee0/derek/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rgee0/derek/downloads","issues_url":"https://api.github.com/repos/rgee0/derek/issues{/number}","pulls_url":"https://api.github.com/repos/rgee0/derek/pulls{/number}","milestones_url":"https://api.github.com/repos/rgee0/derek/milestones{/number}","notifications_url":"https://api.github.com/repos/rgee0/derek/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rgee0/derek/labels{/name}","releases_url":"https://api.github.com/repos/rgee0/derek/releases{/id}","deployments_url":"https://api.github.com/repos/rgee0/derek/deployments","created_at":"2017-10-23T18:36:36Z","updated_at":"2017-10-23T18:36:38Z","pushed_at":"2018-02-22T21:44:43Z","git_url":"git://github.com/rgee0/derek.git","ssh_url":"git@github.com:rgee0/derek.git","clone_url":"https://github.com/rgee0/derek.git","svn_url":"https://github.com/rgee0/derek","homepage":"","size":1160,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"alexellis:master","ref":"master","sha":"7353d0ba82b599919b58801e8c7d1f06a67c2efc","user":{"login":"alexellis","id":6358735,"avatar_url":"https://avatars1.githubusercontent.com/u/6358735?v=4","gravatar_id":"","url":"https://api.github.com/users/alexellis","html_url":"https://github.com/alexellis","followers_url":"https://api.github.com/users/alexellis/followers","following_url":"https://api.github.com/users/alexellis/following{/other_user}","gists_url":"https://api.github.com/users/alexellis/gists{/gist_id}","starred_url":"https://api.github.com/users/alexellis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexellis/subscriptions","organizations_url":"https://api.github.com/users/alexellis/orgs","repos_url":"https://api.github.com/users/alexellis/repos","events_url":"https://api.github.com/users/alexellis/events{/privacy}","received_events_url":"https://api.github.com/users/alexellis/received_events","type":"User","site_admin":false},"repo":{"id":99939503,"name":"derek","full_name":"alexellis/derek","owner":{"login":"alexellis","id":6358735,"avatar_url":"https://avatars1.githubusercontent.com/u/6358735?v=4","gravatar_id":"","url":"https://api.github.com/users/alexellis","html_url":"https://github.com/alexellis","followers_url":"https://api.github.com/users/alexellis/followers","following_url":"https://api.github.com/users/alexellis/following{/other_user}","gists_url":"https://api.github.com/users/alexellis/gists{/gist_id}","starred_url":"https://api.github.com/users/alexellis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexellis/subscriptions","organizations_url":"https://api.github.com/users/alexellis/orgs","repos_url":"https://api.github.com/users/alexellis/repos","events_url":"https://api.github.com/users/alexellis/events{/privacy}","received_events_url":"https://api.github.com/users/alexellis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexellis/derek","description":"derek - a serverless :robot: to manage PRs and issues","fork":false,"url":"https://api.github.com/repos/alexellis/derek","forks_url":"https://api.github.com/repos/alexellis/derek/forks","keys_url":"https://api.github.com/repos/alexellis/derek/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexellis/derek/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexellis/derek/teams","hooks_url":"https://api.github.com/repos/alexellis/derek/hooks","issue_events_url":"https://api.github.com/repos/alexellis/derek/issues/events{/number}","events_url":"https://api.github.com/repos/alexellis/derek/events","assignees_url":"https://api.github.com/repos/alexellis/derek/assignees{/user}","branches_url":"https://api.github.com/repos/alexellis/derek/branches{/branch}","tags_url":"https://api.github.com/repos/alexellis/derek/tags","blobs_url":"https://api.github.com/repos/alexellis/derek/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexellis/derek/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexellis/derek/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexellis/derek/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexellis/derek/statuses/{sha}","languages_url":"https://api.github.com/repos/alexellis/derek/languages","stargazers_url":"https://api.github.com/repos/alexellis/derek/stargazers","contributors_url":"https://api.github.com/repos/alexellis/derek/contributors","subscribers_url":"https://api.github.com/repos/alexellis/derek/subscribers","subscription_url":"https://api.github.com/repos/alexellis/derek/subscription","commits_url":"https://api.github.com/repos/alexellis/derek/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexellis/derek/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexellis/derek/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexellis/derek/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexellis/derek/contents/{+path}","compare_url":"https://api.github.com/repos/alexellis/derek/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexellis/derek/merges","archive_url":"https://api.github.com/repos/alexellis/derek/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexellis/derek/downloads","issues_url":"https://api.github.com/repos/alexellis/derek/issues{/number}","pulls_url":"https://api.github.com/repos/alexellis/derek/pulls{/number}","milestones_url":"https://api.github.com/repos/alexellis/derek/milestones{/number}","notifications_url":"https://api.github.com/repos/alexellis/derek/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexellis/derek/labels{/name}","releases_url":"https://api.github.com/repos/alexellis/derek/releases{/id}","deployments_url":"https://api.github.com/repos/alexellis/derek/deployments","created_at":"2017-08-10T15:43:55Z","updated_at":"2018-03-03T11:14:12Z","pushed_at":"2018-02-24T20:11:56Z","git_url":"git://github.com/alexellis/derek.git","ssh_url":"git@github.com:alexellis/derek.git","clone_url":"https://github.com/alexellis/derek.git","svn_url":"https://github.com/alexellis/derek","homepage":"https://blog.alexellis.io/derek/","size":1155,"stargazers_count":188,"watchers_count":188,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":15,"open_issues":12,"watchers":188,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alexellis/derek/pulls/34"},"html":{"href":"https://github.com/alexellis/derek/pull/34"},"issue":{"href":"https://api.github.com/repos/alexellis/derek/issues/34"},"comments":{"href":"https://api.github.com/repos/alexellis/derek/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/alexellis/derek/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/alexellis/derek/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alexellis/derek/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/alexellis/derek/statuses/e51bb8a412f4e376daca25bc507cedbdade39b89"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"alexellis"}}