File tree Expand file tree Collapse file tree 4 files changed +47
-2
lines changed Expand file tree Collapse file tree 4 files changed +47
-2
lines changed Original file line number Diff line number Diff line change 11node_modules /
22artifacts /
33features /* .feature
4+ package-lock.json
Original file line number Diff line number Diff line change @@ -406,6 +406,17 @@ class ScmRouter extends Scm {
406406 _getBranchList ( config ) {
407407 return this . chooseScm ( config ) . then ( scm => scm . getBranchList ( config ) ) ;
408408 }
409+
410+ /**
411+ * Open a pull request on the repository
412+ * @method _openPr
413+ * @param {Object } config Configuration
414+ * @param {String } config.scmContext Name of scm context
415+ * @return {Object } Created PR
416+ */
417+ _openPr ( config ) {
418+ return this . chooseScm ( config ) . then ( scm => scm . openPr ( config ) ) ;
419+ }
409420}
410421
411422module . exports = ScmRouter ;
Original file line number Diff line number Diff line change 4343 },
4444 "dependencies" : {
4545 "async" : " ^2.6.1" ,
46- "screwdriver-scm-base" : " ^5 .0.0" ,
46+ "screwdriver-scm-base" : " ^6 .0.0" ,
4747 "screwdriver-logger" : " ^1.0.0"
4848 },
4949 "release" : {
Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ describe('index test', () => {
5353 'getChangedFiles' ,
5454 'getOpenedPRs' ,
5555 'getPrInfo' ,
56- 'getBranchList'
56+ 'getBranchList' ,
57+ 'openPr'
5758 ] . forEach ( ( method ) => {
5859 mock [ method ] = sinon . stub ( ) . resolves ( plugin ) ;
5960 } ) ;
@@ -980,4 +981,36 @@ describe('index test', () => {
980981 } ) ;
981982 } ) ;
982983 } ) ;
984+
985+ describe ( '_openPr' , ( ) => {
986+ const config = {
987+ checkoutUrl : 'git@github.com:screwdriver-cd/scm-github.git#master' ,
988+ token : 'thisisatoken' ,
989+ files : [ {
990+ name : 'file.txt' ,
991+ content : 'content'
992+ } , {
993+ name : 'file2.txt' ,
994+ content : 'content'
995+ } ] ,
996+ title : 'update file' ,
997+ message : 'update file' ,
998+ scmContext : 'example.context'
999+ } ;
1000+
1001+ it ( 'call origin openPr' , ( ) => {
1002+ const scmGithub = scm . scms [ 'github.context' ] ;
1003+ const exampleScm = scm . scms [ 'example.context' ] ;
1004+ const scmGitlab = scm . scms [ 'gitlab.context' ] ;
1005+
1006+ return scm . _openPr ( config )
1007+ . then ( ( result ) => {
1008+ assert . strictEqual ( result , 'example' ) ;
1009+ assert . notCalled ( scmGithub . openPr ) ;
1010+ assert . notCalled ( scmGitlab . openPr ) ;
1011+ assert . calledOnce ( exampleScm . openPr ) ;
1012+ assert . calledWith ( exampleScm . openPr , config ) ;
1013+ } ) ;
1014+ } ) ;
1015+ } ) ;
9831016} ) ;
You can’t perform that action at this time.
0 commit comments