@@ -365,27 +365,23 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes
365
365
ctx := NewAPITestContext (t , baseCtx .Username , baseCtx .Reponame , auth_model .AccessTokenScopeWriteRepository )
366
366
367
367
// Protect branch without any whitelisting
368
- t .Run ("ProtectBranchNoWhitelist" , func (t * testing.T ) {
369
- doProtectBranch (ctx , "protected" , "" , "" , "" , "" )
370
- })
368
+ t .Run ("ProtectBranchNoWhitelist" , doProtectBranch (ctx , "protected" , "" , "" , "" , "" ))
371
369
372
370
// Try to push without permissions, which should fail
373
371
t .Run ("TryPushWithoutPermissions" , func (t * testing.T ) {
374
372
_ ,
err := generateCommitWithNewData (
testFileSizeSmall ,
dstPath ,
"[email protected] " ,
"User Two" ,
"branch-data-file-" )
375
373
assert .NoError (t , err )
376
- doGitPushTestRepositoryFail (dstPath , "origin" , "protected" )
374
+ doGitPushTestRepositoryFail (dstPath , "origin" , "protected" )( t )
377
375
})
378
376
379
377
// Set up permissions for normal push but not force push
380
- t .Run ("SetupNormalPushPermissions" , func (t * testing.T ) {
381
- doProtectBranch (ctx , "protected" , baseCtx .Username , "" , "" , "" )
382
- })
378
+ t .Run ("SetupNormalPushPermissions" , doProtectBranch (ctx , "protected" , baseCtx .Username , "" , "" , "" ))
383
379
384
380
// Normal push should work
385
381
t .Run ("NormalPushWithPermissions" , func (t * testing.T ) {
386
382
_ ,
err := generateCommitWithNewData (
testFileSizeSmall ,
dstPath ,
"[email protected] " ,
"User Two" ,
"branch-data-file-" )
387
383
assert .NoError (t , err )
388
- doGitPushTestRepository (dstPath , "origin" , "protected" )
384
+ doGitPushTestRepository (dstPath , "origin" , "protected" )( t )
389
385
})
390
386
391
387
// Try to force push without force push permissions, which should fail
@@ -395,28 +391,20 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes
395
391
_ ,
err := generateCommitWithNewData (
testFileSizeSmall ,
dstPath ,
"[email protected] " ,
"User Two" ,
"branch-data-file-new" )
396
392
assert .NoError (t , err )
397
393
})
398
- doGitPushTestRepositoryFail (dstPath , "-f" , "origin" , "protected" )
394
+ doGitPushTestRepositoryFail (dstPath , "-f" , "origin" , "protected" )( t )
399
395
})
400
396
401
397
// Set up permissions for force push but not normal push
402
- t .Run ("SetupForcePushPermissions" , func (t * testing.T ) {
403
- doProtectBranch (ctx , "protected" , "" , baseCtx .Username , "" , "" )
404
- })
398
+ t .Run ("SetupForcePushPermissions" , doProtectBranch (ctx , "protected" , "" , baseCtx .Username , "" , "" ))
405
399
406
400
// Try to force push without normal push permissions, which should fail
407
- t .Run ("ForcePushWithoutNormalPermissions" , func (t * testing.T ) {
408
- doGitPushTestRepositoryFail (dstPath , "-f" , "origin" , "protected" )
409
- })
401
+ t .Run ("ForcePushWithoutNormalPermissions" , doGitPushTestRepositoryFail (dstPath , "-f" , "origin" , "protected" ))
410
402
411
403
// Set up permissions for normal and force push (both are required to force push)
412
- t .Run ("SetupNormalAndForcePushPermissions" , func (t * testing.T ) {
413
- doProtectBranch (ctx , "protected" , baseCtx .Username , baseCtx .Username , "" , "" )
414
- })
404
+ t .Run ("SetupNormalAndForcePushPermissions" , doProtectBranch (ctx , "protected" , baseCtx .Username , baseCtx .Username , "" , "" ))
415
405
416
406
// Force push should now work
417
- t .Run ("ForcePushWithPermissions" , func (t * testing.T ) {
418
- doGitPushTestRepository (dstPath , "-f" , "origin" , "protected" )
419
- })
407
+ t .Run ("ForcePushWithPermissions" , doGitPushTestRepository (dstPath , "-f" , "origin" , "protected" ))
420
408
421
409
t .Run ("ProtectProtectedBranchNoWhitelist" , doProtectBranch (ctx , "protected" , "" , "" , "" , "" ))
422
410
t .Run ("PushToUnprotectedBranch" , doGitPushTestRepository (dstPath , "origin" , "protected:unprotected" ))
0 commit comments