@@ -15,7 +15,7 @@ const wrapCallback = (func: { (callback: any): void }) => {
1515
1616describe ( 'git' , ( ) => {
1717 test ( 'create, push to, and clone a repo' , async ( ) => {
18- expect . assertions ( 11 ) ;
18+ expect . assertions ( 12 ) ;
1919
2020 let lastCommit : string ;
2121
@@ -29,9 +29,11 @@ describe('git', () => {
2929 fs . mkdirSync ( srcDir , '0700' ) ;
3030 fs . mkdirSync ( dstDir , '0700' ) ;
3131
32- const repos = new Git < number > ( repoDir , {
32+ const repos = new Git < string > ( repoDir , {
3333 autoCreate : true ,
34- authenticate : ( ) => 42 ,
34+ authenticate : ( opts ) => {
35+ return 'my request context' ;
36+ } ,
3537 } ) ;
3638 const port = Math . floor ( Math . random ( ) * ( ( 1 << 16 ) - 1e4 ) ) + 1e4 ;
3739 const server = http
@@ -43,7 +45,7 @@ describe('git', () => {
4345 process . chdir ( srcDir ) ;
4446
4547 repos . on ( 'push' , ( push ) => {
46- expect ( push . context ) . toBe ( 42 ) ;
48+ expect ( push . context ) . toBe ( 'my request context' ) ;
4749
4850 expect ( push . repo ) . toBe ( 'xyz/doom' ) ;
4951 expect ( push . commit ) . toBe ( lastCommit ) ;
@@ -658,9 +660,9 @@ describe('git', () => {
658660
659661 const repos = new Git ( repoDir , {
660662 autoCreate : true ,
661- authenticate : async ( { type, repo, user } ) => {
663+ authenticate : async ( { type, repo, getUser } ) => {
662664 if ( type === 'fetch' && repo === 'doom' ) {
663- const [ username , password ] = await user ( ) ;
665+ const [ username , password ] = await getUser ( ) ;
664666 if ( username == 'root' && password == 'root' ) {
665667 return ;
666668 } else {
@@ -729,15 +731,15 @@ describe('git', () => {
729731
730732 const repos = new Git < Context > ( repoDir , {
731733 autoCreate : true ,
732- authenticate : async ( { type, repo, user , headers } ) => {
734+ authenticate : async ( { type, repo, getUser , headers } ) => {
733735 if ( type === 'fetch' && repo === 'doom' ) {
734736 expect ( headers [ 'host' ] ) . toBeTruthy ( ) ;
735737 expect ( headers [ 'user-agent' ] ) . toBeTruthy ( ) ;
736738 expect ( headers [ 'accept' ] ) . toBeTruthy ( ) ;
737739 expect ( headers [ 'pragma' ] ) . toBeTruthy ( ) ;
738740 expect ( headers [ 'accept-encoding' ] ) . toBeTruthy ( ) ;
739741
740- const [ username , password ] = await user ( ) ;
742+ const [ username , password ] = await getUser ( ) ;
741743 if ( username == 'root' && password == 'root' ) {
742744 return {
743745 username : username ,
@@ -802,20 +804,14 @@ describe('git', () => {
802804
803805 const repos = new Git ( repoDir , {
804806 autoCreate : true ,
805- authenticate : ( { type, repo, user } ) => {
806- return new Promise ( function ( resolve , reject ) {
807- if ( type === 'fetch' && repo === 'doom' ) {
808- user ( ( username , password ) => {
809- if ( username == 'root' && password == 'root' ) {
810- return resolve ( void 0 ) ;
811- } else {
812- return reject ( 'that is not the correct password' ) ;
813- }
814- } ) ;
815- } else {
816- return reject ( 'that is not the correct password' ) ;
807+ authenticate : async ( { type, repo, getUser } ) => {
808+ if ( type === 'fetch' && repo === 'doom' ) {
809+ const [ username , password ] = await getUser ( ) ;
810+ if ( username == 'root' && password == 'root' ) {
811+ return ;
817812 }
818- } ) ;
813+ }
814+ throw new Error ( 'that is not the correct password' ) ;
819815 } ,
820816 } ) ;
821817 const port = Math . floor ( Math . random ( ) * ( ( 1 << 16 ) - 1e4 ) ) + 1e4 ;
0 commit comments