{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/kibana/pulls/comments/34487159","id":34487159,"diff_hunk":"@@ -0,0 +1,130 @@\n+var root = require('requirefrom')('');\n+var plugin = root('src/server/bin/plugin/plugin');\n+var expect = require('expect.js');\n+var sinon = require('sinon');\n+var installer = root('src/server/bin/plugin/pluginInstaller');\n+var remover = root('src/server/bin/plugin/pluginRemover');\n+var settingParser = root('src/server/bin/plugin/settingParser');\n+\n+describe('kibana cli', function () {\n+\n+  describe('plugin installer', function () {\n+\n+    describe('settings.action', function () {\n+\n+      var program = {\n+        command: function () { return program; },\n+        description: function () { return program; },\n+        option: function () { return program; },\n+        action: function (processCommand) {\n+          processCommand();\n+        }\n+      };\n+\n+      beforeEach(function () {\n+        sinon.stub(remover, 'remove');\n+        sinon.stub(installer, 'install');\n+      });\n+\n+      afterEach(function () {\n+        remover.remove.restore();\n+        installer.install.restore();\n+        settingParser.parse.restore();\n+      });\n+\n+      it('should call remove if settings.action is \"remove\"', function () {\n+        sinon.stub(settingParser, 'parse', function () {\n+          return {\n+            action: 'remove'\n+          };\n+        });\n+\n+        plugin(program);","path":"test/unit/server/bin/plugin/plugin.js","position":null,"original_position":42,"commit_id":"3b0c0bf559ce1235b7d487fce6bdcf86ef1578be","original_commit_id":"6a5978145db8e2d6eb760d24af78c4dd622f87f8","user":{"login":"BigFunger","id":12193008,"avatar_url":"https://avatars.githubusercontent.com/u/12193008?v=3","gravatar_id":"","url":"https://api.github.com/users/BigFunger","html_url":"https://github.com/BigFunger","followers_url":"https://api.github.com/users/BigFunger/followers","following_url":"https://api.github.com/users/BigFunger/following{/other_user}","gists_url":"https://api.github.com/users/BigFunger/gists{/gist_id}","starred_url":"https://api.github.com/users/BigFunger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BigFunger/subscriptions","organizations_url":"https://api.github.com/users/BigFunger/orgs","repos_url":"https://api.github.com/users/BigFunger/repos","events_url":"https://api.github.com/users/BigFunger/events{/privacy}","received_events_url":"https://api.github.com/users/BigFunger/received_events","type":"User","site_admin":false},"body":"I made this change, however I was not 100% comfortable with it. In this specific scenario, the code you suggested seemed to be more complex, and just as long as the original code. I've also always tried to make my unit tests as simple and straightforward as they can be. Which inherently leads to more verbose code and some copy-pasting, but in theory leads to less bugs in the test code. (However arguments can be made that any time you copy-paste-edit you run the risk of adding easy-to-miss bugs that way too)\r\n\r\nThe argument against your suggestion is harder to make regarding the changes I checked in to the progressReporter tests. I followed the suggested pattern for this file and it reduced the code dramatically.","created_at":"2015-07-13T17:20:30Z","updated_at":"2015-07-13T17:20:30Z","html_url":"https://github.com/elastic/kibana/pull/4406#discussion_r34487159","pull_request_url":"https://api.github.com/repos/elastic/kibana/pulls/4406","_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments/34487159"},"html":{"href":"https://github.com/elastic/kibana/pull/4406#discussion_r34487159"},"pull_request":{"href":"https://api.github.com/repos/elastic/kibana/pulls/4406"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/kibana/pulls/4406","id":39590122,"html_url":"https://github.com/elastic/kibana/pull/4406","diff_url":"https://github.com/elastic/kibana/pull/4406.diff","patch_url":"https://github.com/elastic/kibana/pull/4406.patch","issue_url":"https://api.github.com/repos/elastic/kibana/issues/4406","number":4406,"state":"open","locked":false,"title":"Install plugin","user":{"login":"BigFunger","id":12193008,"avatar_url":"https://avatars.githubusercontent.com/u/12193008?v=3","gravatar_id":"","url":"https://api.github.com/users/BigFunger","html_url":"https://github.com/BigFunger","followers_url":"https://api.github.com/users/BigFunger/followers","following_url":"https://api.github.com/users/BigFunger/following{/other_user}","gists_url":"https://api.github.com/users/BigFunger/gists{/gist_id}","starred_url":"https://api.github.com/users/BigFunger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BigFunger/subscriptions","organizations_url":"https://api.github.com/users/BigFunger/orgs","repos_url":"https://api.github.com/users/BigFunger/repos","events_url":"https://api.github.com/users/BigFunger/events{/privacy}","received_events_url":"https://api.github.com/users/BigFunger/received_events","type":"User","site_admin":false},"body":"Addresses #4204\r\nCreates the Kibana plugin install cli.\r\n\r\n- Removes the startup specific logic from the kibana.js file.\r\n- Moves the commander configuration for the default command into its own file\r\n- Moves the actual startup logic into its own file\r\n- Adds the plugin subcommand and all related logic\r\n- Adds unit test coverage for the majority of the new plugin subcommand logic\r\n\r\nTo use:\r\nfrom the src/server/bin folder, type:\r\n```\r\nnode kibana plugin -h\r\n```","created_at":"2015-07-09T14:39:27Z","updated_at":"2015-07-13T17:20:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"edb82d14890f33a39cfcd36047bfc266749a89b2","assignee":{"login":"BigFunger","id":12193008,"avatar_url":"https://avatars.githubusercontent.com/u/12193008?v=3","gravatar_id":"","url":"https://api.github.com/users/BigFunger","html_url":"https://github.com/BigFunger","followers_url":"https://api.github.com/users/BigFunger/followers","following_url":"https://api.github.com/users/BigFunger/following{/other_user}","gists_url":"https://api.github.com/users/BigFunger/gists{/gist_id}","starred_url":"https://api.github.com/users/BigFunger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BigFunger/subscriptions","organizations_url":"https://api.github.com/users/BigFunger/orgs","repos_url":"https://api.github.com/users/BigFunger/repos","events_url":"https://api.github.com/users/BigFunger/events{/privacy}","received_events_url":"https://api.github.com/users/BigFunger/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/elastic/kibana/pulls/4406/commits","review_comments_url":"https://api.github.com/repos/elastic/kibana/pulls/4406/comments","review_comment_url":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/kibana/issues/4406/comments","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/3b0c0bf559ce1235b7d487fce6bdcf86ef1578be","head":{"label":"BigFunger:install-plugin","ref":"install-plugin","sha":"3b0c0bf559ce1235b7d487fce6bdcf86ef1578be","user":{"login":"BigFunger","id":12193008,"avatar_url":"https://avatars.githubusercontent.com/u/12193008?v=3","gravatar_id":"","url":"https://api.github.com/users/BigFunger","html_url":"https://github.com/BigFunger","followers_url":"https://api.github.com/users/BigFunger/followers","following_url":"https://api.github.com/users/BigFunger/following{/other_user}","gists_url":"https://api.github.com/users/BigFunger/gists{/gist_id}","starred_url":"https://api.github.com/users/BigFunger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BigFunger/subscriptions","organizations_url":"https://api.github.com/users/BigFunger/orgs","repos_url":"https://api.github.com/users/BigFunger/repos","events_url":"https://api.github.com/users/BigFunger/events{/privacy}","received_events_url":"https://api.github.com/users/BigFunger/received_events","type":"User","site_admin":false},"repo":{"id":35180828,"name":"kibana","full_name":"BigFunger/kibana","owner":{"login":"BigFunger","id":12193008,"avatar_url":"https://avatars.githubusercontent.com/u/12193008?v=3","gravatar_id":"","url":"https://api.github.com/users/BigFunger","html_url":"https://github.com/BigFunger","followers_url":"https://api.github.com/users/BigFunger/followers","following_url":"https://api.github.com/users/BigFunger/following{/other_user}","gists_url":"https://api.github.com/users/BigFunger/gists{/gist_id}","starred_url":"https://api.github.com/users/BigFunger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BigFunger/subscriptions","organizations_url":"https://api.github.com/users/BigFunger/orgs","repos_url":"https://api.github.com/users/BigFunger/repos","events_url":"https://api.github.com/users/BigFunger/events{/privacy}","received_events_url":"https://api.github.com/users/BigFunger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BigFunger/kibana","description":"Kibana","fork":true,"url":"https://api.github.com/repos/BigFunger/kibana","forks_url":"https://api.github.com/repos/BigFunger/kibana/forks","keys_url":"https://api.github.com/repos/BigFunger/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BigFunger/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BigFunger/kibana/teams","hooks_url":"https://api.github.com/repos/BigFunger/kibana/hooks","issue_events_url":"https://api.github.com/repos/BigFunger/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/BigFunger/kibana/events","assignees_url":"https://api.github.com/repos/BigFunger/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/BigFunger/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/BigFunger/kibana/tags","blobs_url":"https://api.github.com/repos/BigFunger/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BigFunger/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BigFunger/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/BigFunger/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BigFunger/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/BigFunger/kibana/languages","stargazers_url":"https://api.github.com/repos/BigFunger/kibana/stargazers","contributors_url":"https://api.github.com/repos/BigFunger/kibana/contributors","subscribers_url":"https://api.github.com/repos/BigFunger/kibana/subscribers","subscription_url":"https://api.github.com/repos/BigFunger/kibana/subscription","commits_url":"https://api.github.com/repos/BigFunger/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/BigFunger/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/BigFunger/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/BigFunger/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/BigFunger/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/BigFunger/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BigFunger/kibana/merges","archive_url":"https://api.github.com/repos/BigFunger/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BigFunger/kibana/downloads","issues_url":"https://api.github.com/repos/BigFunger/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/BigFunger/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/BigFunger/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/BigFunger/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BigFunger/kibana/labels{/name}","releases_url":"https://api.github.com/repos/BigFunger/kibana/releases{/id}","created_at":"2015-05-06T20:19:18Z","updated_at":"2015-06-03T17:01:46Z","pushed_at":"2015-07-13T17:13:03Z","git_url":"git://github.com/BigFunger/kibana.git","ssh_url":"git@github.com:BigFunger/kibana.git","clone_url":"https://github.com/BigFunger/kibana.git","svn_url":"https://github.com/BigFunger/kibana","homepage":"https://www.elastic.co/products/kibana","size":57029,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"9449f185526eefec92a60c73d2ba37c412eb43bd","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":7833168,"name":"kibana","full_name":"elastic/kibana","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/kibana","description":"Kibana","fork":false,"url":"https://api.github.com/repos/elastic/kibana","forks_url":"https://api.github.com/repos/elastic/kibana/forks","keys_url":"https://api.github.com/repos/elastic/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/kibana/teams","hooks_url":"https://api.github.com/repos/elastic/kibana/hooks","issue_events_url":"https://api.github.com/repos/elastic/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/kibana/events","assignees_url":"https://api.github.com/repos/elastic/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/kibana/tags","blobs_url":"https://api.github.com/repos/elastic/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/kibana/languages","stargazers_url":"https://api.github.com/repos/elastic/kibana/stargazers","contributors_url":"https://api.github.com/repos/elastic/kibana/contributors","subscribers_url":"https://api.github.com/repos/elastic/kibana/subscribers","subscription_url":"https://api.github.com/repos/elastic/kibana/subscription","commits_url":"https://api.github.com/repos/elastic/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/kibana/merges","archive_url":"https://api.github.com/repos/elastic/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/kibana/downloads","issues_url":"https://api.github.com/repos/elastic/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/kibana/labels{/name}","releases_url":"https://api.github.com/repos/elastic/kibana/releases{/id}","created_at":"2013-01-26T04:00:59Z","updated_at":"2015-07-13T17:10:20Z","pushed_at":"2015-07-13T17:13:05Z","git_url":"git://github.com/elastic/kibana.git","ssh_url":"git@github.com:elastic/kibana.git","clone_url":"https://github.com/elastic/kibana.git","svn_url":"https://github.com/elastic/kibana","homepage":"https://www.elastic.co/products/kibana","size":94141,"stargazers_count":3814,"watchers_count":3814,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1410,"mirror_url":null,"open_issues_count":575,"forks":1410,"open_issues":575,"watchers":3814,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/4406"},"html":{"href":"https://github.com/elastic/kibana/pull/4406"},"issue":{"href":"https://api.github.com/repos/elastic/kibana/issues/4406"},"comments":{"href":"https://api.github.com/repos/elastic/kibana/issues/4406/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/kibana/pulls/4406/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/kibana/pulls/4406/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/kibana/statuses/3b0c0bf559ce1235b7d487fce6bdcf86ef1578be"}}}}