@@ -243,6 +243,57 @@ describe("Remote", function() {
243243 } ) ;
244244 } ) ;
245245
246+ it ( "can negotiate push" , function ( ) {
247+ var repo = this . repository ;
248+ var wasCalled = false ;
249+
250+ return Remote . create ( repo , "bare" , bareReposPath )
251+ . then ( function ( remote ) {
252+ var fetchOpts = {
253+ callbacks : {
254+ pushNegotiation : function ( update_list , len ) {
255+ wasCalled = true ;
256+ return NodeGit . Error . CODE . OK ;
257+ }
258+ }
259+ } ;
260+
261+ var ref = "refs/heads/master" ;
262+ var refs = [ ref + ":" + ref ] ;
263+
264+ return remote . push ( refs , fetchOpts )
265+ . then ( function ( res ) {
266+ assert . ok ( wasCalled ) ;
267+ } ) ;
268+ } ) ;
269+ } ) ;
270+
271+ it ( "can reject push during negotiation" , function ( ) {
272+ var repo = this . repository ;
273+
274+ return Remote . create ( repo , "bare" , bareReposPath )
275+ . then ( function ( remote ) {
276+ var fetchOpts = {
277+ callbacks : {
278+ pushNegotiation : function ( update_list , len ) {
279+ return NodeGit . Error . CODE . ERROR ;
280+ }
281+ }
282+ } ;
283+
284+ var ref = "refs/heads/master" ;
285+ var refs = [ ref + ":" + ref ] ;
286+
287+ return remote . push ( refs , fetchOpts ) ;
288+ } )
289+ . then ( function ( ) {
290+ assert . fail ( "push should not succeed" ) ;
291+ } )
292+ . catch ( function ( err ) {
293+ assert . notEqual ( err . code , "ERR_ASSERTION" ) ;
294+ } ) ;
295+ } ) ;
296+
246297 it ( "can get the default branch of a remote" , function ( ) {
247298 var remoteCallbacks = {
248299 certificateCheck : ( ) => 0
0 commit comments