{"action":"created","comment":{"url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/comments/182729251","pull_request_review_id":113582224,"id":182729251,"diff_hunk":"@@ -1,67 +1,212 @@\n const chai = require('chai')\n-const chaiAsPromised = require('chai-as-promised')\n-chai.use(chaiAsPromised)\n+chai.use(require('chai-as-promised'))\n+chai.use(require('sinon-chai'))\n const expect = chai.expect\n+const merge = require('lodash.merge')\n+const sinon = require('sinon')\n+const proxyquire = require('proxyquire')\n \n-const EventGatewayPlugin = require('../src/index.js')\n+let Plugin = require('../src/index.js')\n \n describe('Event Gateway Plugin', () => {\n+  describe('connector functions', () => {\n+    let sandbox\n+    let sdkStub\n+    let serverlessStub\n+\n+    beforeEach(() => {\n+      sandbox = sinon.sandbox.create()\n+\n+      sdkStub = {\n+        registerFunction: sandbox.stub().resolves(),\n+        listFunctions: sandbox.stub().resolves([]),\n+        listSubscriptions: sandbox.stub().resolves([]),\n+        subscribe: sandbox.stub().resolves()\n+      }\n+\n+      Plugin = proxyquire('../src/index.js', {\n+        '@serverless/event-gateway-sdk': function () {\n+          return sdkStub\n+        }\n+      })\n+\n+      serverlessStub = {\n+        service: {\n+          service: 'test',\n+          custom: { eventgateway: { space: 'testspace', apiKey: 'xxx' } },\n+          functions: {},\n+          getAllFunctions: sandbox.stub().returns([])\n+        },\n+        getProvider: sandbox.stub().returns({\n+          getStage: sinon.stub().returns('dev'),\n+          getRegion: sinon.stub().returns('us-east-1'),\n+          naming: { getStackName: sinon.stub().returns('stackname') },\n+          request: sinon.stub().resolves({\n+            Stacks: [\n+              {\n+                Outputs: [\n+                  { OutputKey: 'EventGatewayUserAccessKey', OutputValue: 'ak' },\n+                  { OutputKey: 'EventGatewayUserSecretKey', OutputValue: 'sk' }\n+                ]\n+              }\n+            ]\n+          })\n+        })\n+      }\n+    })\n+\n+    afterEach(() => {\n+      sandbox.restore()\n+    })\n+\n+    it('should register awskinesis function', async () => {\n+      // given\n+      serverlessStub.service.functions = {\n+        saveToKinesis: {\n+          type: 'awskinesis',\n+          inputs: { arn: 'fakearn', streamName: 'testStream' },\n+          events: [{ eventgateway: { event: 'test.tested' } }]\n+        }\n+      }\n+      const plugin = constructPlugin(serverlessStub)\n+\n+      // when\n+      plugin.hooks['package:initialize']()\n+      await plugin.hooks['after:deploy:finalize']()\n+\n+      // then\n+      return expect(sdkStub.registerFunction).calledWith({\n+        functionId: 'test-dev-saveToKinesis',\n+        provider: { streamName: 'testStream', awsAccessKeyId: 'ak', awsSecretAccessKey: 'sk', region: 'us-east-1' },\n+        type: 'awskinesis'\n+      })\n+    })\n+\n+    it('should throw error if connector function has no inputs', async () => {\n+      // given\n+      const funcName = 'saveToFirehose'\n+      const funcType = 'awssqs'\n+      const func = {\n+        type: funcType,\n+        inputs: {},\n+        events: [{ eventgateway: { event: 'test.tested' } }]\n+      }\n+      serverlessStub.service.functions = {}\n+      serverlessStub.service.functions[funcName] = func\n+\n+      const plugin = constructPlugin(serverlessStub)\n+      sdkStub.registerFunction = sandbox.stub().rejects('Error')\n+\n+      return expect(plugin.hooks['package:initialize']).to.throw(\n+        `Invalid inputs for ${funcType} function \"${funcName}\". ` +\n+        `You provided: none. Please provide either \"logicalId\" or both \"arn\" and \"queueUrl\" inputs.`\n+      )\n+    })\n+\n+    it('should throw error if connector function inputs incomplete', async () => {","path":"test/index.js","position":109,"original_position":109,"commit_id":"dfd717483939528d6dc2f8a93ba020ad28cf30ef","original_commit_id":"dfd717483939528d6dc2f8a93ba020ad28cf30ef","user":{"login":"mthenw","id":455261,"avatar_url":"https://avatars2.githubusercontent.com/u/455261?v=4","gravatar_id":"","url":"https://api.github.com/users/mthenw","html_url":"https://github.com/mthenw","followers_url":"https://api.github.com/users/mthenw/followers","following_url":"https://api.github.com/users/mthenw/following{/other_user}","gists_url":"https://api.github.com/users/mthenw/gists{/gist_id}","starred_url":"https://api.github.com/users/mthenw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mthenw/subscriptions","organizations_url":"https://api.github.com/users/mthenw/orgs","repos_url":"https://api.github.com/users/mthenw/repos","events_url":"https://api.github.com/users/mthenw/events{/privacy}","received_events_url":"https://api.github.com/users/mthenw/received_events","type":"User","site_admin":false},"body":"can you add similar tests or awsfirehose and awssqs?","created_at":"2018-04-19T12:33:49Z","updated_at":"2018-04-19T12:34:54Z","html_url":"https://github.com/serverless/serverless-event-gateway-plugin/pull/47#discussion_r182729251","pull_request_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/47","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/comments/182729251"},"html":{"href":"https://github.com/serverless/serverless-event-gateway-plugin/pull/47#discussion_r182729251"},"pull_request":{"href":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/47"}}},"pull_request":{"url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/47","id":181494213,"html_url":"https://github.com/serverless/serverless-event-gateway-plugin/pull/47","diff_url":"https://github.com/serverless/serverless-event-gateway-plugin/pull/47.diff","patch_url":"https://github.com/serverless/serverless-event-gateway-plugin/pull/47.patch","issue_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues/47","number":47,"state":"open","locked":false,"title":"Connector functions","user":{"login":"elsteelbrain","id":10067728,"avatar_url":"https://avatars0.githubusercontent.com/u/10067728?v=4","gravatar_id":"","url":"https://api.github.com/users/elsteelbrain","html_url":"https://github.com/elsteelbrain","followers_url":"https://api.github.com/users/elsteelbrain/followers","following_url":"https://api.github.com/users/elsteelbrain/following{/other_user}","gists_url":"https://api.github.com/users/elsteelbrain/gists{/gist_id}","starred_url":"https://api.github.com/users/elsteelbrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elsteelbrain/subscriptions","organizations_url":"https://api.github.com/users/elsteelbrain/orgs","repos_url":"https://api.github.com/users/elsteelbrain/repos","events_url":"https://api.github.com/users/elsteelbrain/events{/privacy}","received_events_url":"https://api.github.com/users/elsteelbrain/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-13T13:50:37Z","updated_at":"2018-04-19T12:34:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4bb5ecd71f35a19da410691408ce5cdf7fc3c8de","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/47/commits","review_comments_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/47/comments","review_comment_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues/47/comments","statuses_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/statuses/dfd717483939528d6dc2f8a93ba020ad28cf30ef","head":{"label":"serverless:connector-functions","ref":"connector-functions","sha":"dfd717483939528d6dc2f8a93ba020ad28cf30ef","user":{"login":"serverless","id":13742415,"avatar_url":"https://avatars0.githubusercontent.com/u/13742415?v=4","gravatar_id":"","url":"https://api.github.com/users/serverless","html_url":"https://github.com/serverless","followers_url":"https://api.github.com/users/serverless/followers","following_url":"https://api.github.com/users/serverless/following{/other_user}","gists_url":"https://api.github.com/users/serverless/gists{/gist_id}","starred_url":"https://api.github.com/users/serverless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serverless/subscriptions","organizations_url":"https://api.github.com/users/serverless/orgs","repos_url":"https://api.github.com/users/serverless/repos","events_url":"https://api.github.com/users/serverless/events{/privacy}","received_events_url":"https://api.github.com/users/serverless/received_events","type":"Organization","site_admin":false},"repo":{"id":119378433,"name":"serverless-event-gateway-plugin","full_name":"serverless/serverless-event-gateway-plugin","owner":{"login":"serverless","id":13742415,"avatar_url":"https://avatars0.githubusercontent.com/u/13742415?v=4","gravatar_id":"","url":"https://api.github.com/users/serverless","html_url":"https://github.com/serverless","followers_url":"https://api.github.com/users/serverless/followers","following_url":"https://api.github.com/users/serverless/following{/other_user}","gists_url":"https://api.github.com/users/serverless/gists{/gist_id}","starred_url":"https://api.github.com/users/serverless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serverless/subscriptions","organizations_url":"https://api.github.com/users/serverless/orgs","repos_url":"https://api.github.com/users/serverless/repos","events_url":"https://api.github.com/users/serverless/events{/privacy}","received_events_url":"https://api.github.com/users/serverless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/serverless/serverless-event-gateway-plugin","description":"Event Gateway plugin for Serverless Framework","fork":false,"url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin","forks_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/forks","keys_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/teams","hooks_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/hooks","issue_events_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/events","assignees_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/tags","blobs_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/languages","stargazers_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/stargazers","contributors_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/contributors","subscribers_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/subscribers","subscription_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/subscription","commits_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/merges","archive_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/downloads","issues_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/labels{/name}","releases_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/deployments","created_at":"2018-01-29T12:16:21Z","updated_at":"2018-04-17T13:26:09Z","pushed_at":"2018-04-19T12:30:50Z","git_url":"git://github.com/serverless/serverless-event-gateway-plugin.git","ssh_url":"git@github.com:serverless/serverless-event-gateway-plugin.git","clone_url":"https://github.com/serverless/serverless-event-gateway-plugin.git","svn_url":"https://github.com/serverless/serverless-event-gateway-plugin","homepage":"","size":284,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":4,"default_branch":"master"}},"base":{"label":"serverless:master","ref":"master","sha":"8796596e322973470e6075701be360b6d14d98b6","user":{"login":"serverless","id":13742415,"avatar_url":"https://avatars0.githubusercontent.com/u/13742415?v=4","gravatar_id":"","url":"https://api.github.com/users/serverless","html_url":"https://github.com/serverless","followers_url":"https://api.github.com/users/serverless/followers","following_url":"https://api.github.com/users/serverless/following{/other_user}","gists_url":"https://api.github.com/users/serverless/gists{/gist_id}","starred_url":"https://api.github.com/users/serverless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serverless/subscriptions","organizations_url":"https://api.github.com/users/serverless/orgs","repos_url":"https://api.github.com/users/serverless/repos","events_url":"https://api.github.com/users/serverless/events{/privacy}","received_events_url":"https://api.github.com/users/serverless/received_events","type":"Organization","site_admin":false},"repo":{"id":119378433,"name":"serverless-event-gateway-plugin","full_name":"serverless/serverless-event-gateway-plugin","owner":{"login":"serverless","id":13742415,"avatar_url":"https://avatars0.githubusercontent.com/u/13742415?v=4","gravatar_id":"","url":"https://api.github.com/users/serverless","html_url":"https://github.com/serverless","followers_url":"https://api.github.com/users/serverless/followers","following_url":"https://api.github.com/users/serverless/following{/other_user}","gists_url":"https://api.github.com/users/serverless/gists{/gist_id}","starred_url":"https://api.github.com/users/serverless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serverless/subscriptions","organizations_url":"https://api.github.com/users/serverless/orgs","repos_url":"https://api.github.com/users/serverless/repos","events_url":"https://api.github.com/users/serverless/events{/privacy}","received_events_url":"https://api.github.com/users/serverless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/serverless/serverless-event-gateway-plugin","description":"Event Gateway plugin for Serverless Framework","fork":false,"url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin","forks_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/forks","keys_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/teams","hooks_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/hooks","issue_events_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/events","assignees_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/tags","blobs_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/languages","stargazers_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/stargazers","contributors_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/contributors","subscribers_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/subscribers","subscription_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/subscription","commits_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/merges","archive_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/downloads","issues_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/labels{/name}","releases_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/deployments","created_at":"2018-01-29T12:16:21Z","updated_at":"2018-04-17T13:26:09Z","pushed_at":"2018-04-19T12:30:50Z","git_url":"git://github.com/serverless/serverless-event-gateway-plugin.git","ssh_url":"git@github.com:serverless/serverless-event-gateway-plugin.git","clone_url":"https://github.com/serverless/serverless-event-gateway-plugin.git","svn_url":"https://github.com/serverless/serverless-event-gateway-plugin","homepage":"","size":284,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/47"},"html":{"href":"https://github.com/serverless/serverless-event-gateway-plugin/pull/47"},"issue":{"href":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues/47"},"comments":{"href":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/issues/47/comments"},"review_comments":{"href":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/47/comments"},"review_comment":{"href":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/pulls/47/commits"},"statuses":{"href":"https://api.github.com/repos/serverless/serverless-event-gateway-plugin/statuses/dfd717483939528d6dc2f8a93ba020ad28cf30ef"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"mthenw"}}