File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,17 @@ class ScmRouter extends Scm {
154154 return this . chooseScm ( config ) . then ( scm => scm . addWebhook ( config ) ) ;
155155 }
156156
157+ /**
158+ * Parse the url for a repo for the specific source control
159+ * @method _addDeployKey
160+ * @param {Object } config Configuration
161+ * @param {String } config.scmContext Name of scm context
162+ * @return {Promise }
163+ */
164+ _addDeployKey ( config ) {
165+ return this . chooseScm ( config ) . then ( scm => scm . addDeployKey ( config ) ) ;
166+ }
167+
157168 /**
158169 * Parse the url for a repo for the specific source control
159170 * @method _parseUrl
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ describe('index test', () => {
3737 'dummyFunction' ,
3838 'dummyRejectFunction' ,
3939 'addWebhook' ,
40+ 'addDeployKey' ,
4041 'parseUrl' ,
4142 'parseHook' ,
4243 'getCheckoutCommand' ,
@@ -561,6 +562,25 @@ describe('index test', () => {
561562 } ) ;
562563 } ) ;
563564
565+ describe ( '_addDeployKey' , ( ) => {
566+ const config = { scmContext : 'example.context' } ;
567+
568+ it ( 'call origin addDeployKey' , ( ) => {
569+ const scmGithub = scm . scms [ 'github.context' ] ;
570+ const exampleScm = scm . scms [ 'example.context' ] ;
571+ const scmGitlab = scm . scms [ 'gitlab.context' ] ;
572+
573+ return scm . _addDeployKey ( config )
574+ . then ( ( result ) => {
575+ assert . strictEqual ( result , 'example' ) ;
576+ assert . notCalled ( scmGithub . addDeployKey ) ;
577+ assert . notCalled ( scmGitlab . addDeployKey ) ;
578+ assert . calledOnce ( exampleScm . addDeployKey ) ;
579+ assert . calledWith ( exampleScm . addDeployKey , config ) ;
580+ } ) ;
581+ } ) ;
582+ } ) ;
583+
564584 describe ( '_parseUrl' , ( ) => {
565585 const config = { scmContext : 'example.context' } ;
566586
You can’t perform that action at this time.
0 commit comments