@@ -71,7 +71,6 @@ func testGit(t *testing.T, u *url.URL) {
71
71
t .Run ("BranchProtectMerge" , doBranchProtectPRMerge (& httpContext , dstPath ))
72
72
t .Run ("MergeFork" , func (t * testing.T ) {
73
73
t .Run ("CreatePRAndMerge" , doMergeFork (httpContext , forkedUserCtx , "master" , httpContext .Username + ":master" ))
74
- t .Run ("DeleteRepository" , doAPIDeleteRepository (httpContext ))
75
74
rawTest (t , & forkedUserCtx , little , big , littleLFS , bigLFS )
76
75
mediaTest (t , & forkedUserCtx , little , big , littleLFS , bigLFS )
77
76
})
@@ -111,7 +110,6 @@ func testGit(t *testing.T, u *url.URL) {
111
110
t .Run ("BranchProtectMerge" , doBranchProtectPRMerge (& sshContext , dstPath ))
112
111
t .Run ("MergeFork" , func (t * testing.T ) {
113
112
t .Run ("CreatePRAndMerge" , doMergeFork (sshContext , forkedUserCtx , "master" , sshContext .Username + ":master" ))
114
- t .Run ("DeleteRepository" , doAPIDeleteRepository (sshContext ))
115
113
rawTest (t , & forkedUserCtx , little , big , littleLFS , bigLFS )
116
114
mediaTest (t , & forkedUserCtx , little , big , littleLFS , bigLFS )
117
115
})
@@ -419,8 +417,62 @@ func doMergeFork(ctx, baseCtx APITestContext, baseBranch, headBranch string) fun
419
417
pr , err = doAPICreatePullRequest (ctx , baseCtx .Username , baseCtx .Reponame , baseBranch , headBranch )(t )
420
418
assert .NoError (t , err )
421
419
})
420
+ t .Run ("EnsureCanSeePull" , func (t * testing.T ) {
421
+ req := NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
422
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
423
+ req = NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d/files" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
424
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
425
+ req = NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d/commits" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
426
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
427
+ })
428
+ var diffStr string
429
+ t .Run ("GetDiff" , func (t * testing.T ) {
430
+ req := NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d.diff" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
431
+ resp := ctx .Session .MakeRequest (t , req , http .StatusOK )
432
+ diffStr = resp .Body .String ()
433
+ })
422
434
t .Run ("MergePR" , doAPIMergePullRequest (baseCtx , baseCtx .Username , baseCtx .Reponame , pr .Index ))
423
-
435
+ t .Run ("EnsureCanSeePull" , func (t * testing.T ) {
436
+ req := NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
437
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
438
+ req = NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d/files" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
439
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
440
+ req = NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d/commits" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
441
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
442
+ })
443
+ t .Run ("EnsureDiffNoChange" , func (t * testing.T ) {
444
+ req := NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d.diff" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
445
+ resp := ctx .Session .MakeRequest (t , req , http .StatusOK )
446
+ assert .Equal (t , diffStr , resp .Body .String ())
447
+ })
448
+ t .Run ("DeleteHeadBranch" , doBranchDelete (baseCtx , baseCtx .Username , baseCtx .Reponame , headBranch ))
449
+ t .Run ("EnsureCanSeePull" , func (t * testing.T ) {
450
+ req := NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
451
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
452
+ req = NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d/files" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
453
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
454
+ req = NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d/commits" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
455
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
456
+ })
457
+ t .Run ("EnsureDiffNoChange" , func (t * testing.T ) {
458
+ req := NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d.diff" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
459
+ resp := ctx .Session .MakeRequest (t , req , http .StatusOK )
460
+ assert .Equal (t , diffStr , resp .Body .String ())
461
+ })
462
+ t .Run ("DeleteRepository" , doAPIDeleteRepository (ctx ))
463
+ t .Run ("EnsureCanSeePull" , func (t * testing.T ) {
464
+ req := NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
465
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
466
+ req = NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d/files" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
467
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
468
+ req = NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d/commits" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
469
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
470
+ })
471
+ t .Run ("EnsureDiffNoChange" , func (t * testing.T ) {
472
+ req := NewRequest (t , "GET" , fmt .Sprintf ("/%s/%s/pulls/%d.diff" , url .PathEscape (baseCtx .Username ), url .PathEscape (baseCtx .Reponame ), pr .Index ))
473
+ resp := ctx .Session .MakeRequest (t , req , http .StatusOK )
474
+ assert .Equal (t , diffStr , resp .Body .String ())
475
+ })
424
476
}
425
477
}
426
478
@@ -493,3 +545,14 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
493
545
assert .True (t , repo .IsPrivate )
494
546
}
495
547
}
548
+
549
+ func doBranchDelete (ctx APITestContext , owner , repo , branch string ) func (* testing.T ) {
550
+ return func (t * testing.T ) {
551
+ csrf := GetCSRF (t , ctx .Session , fmt .Sprintf ("/%s/%s/branches" , url .PathEscape (owner ), url .PathEscape (repo )))
552
+
553
+ req := NewRequestWithValues (t , "POST" , fmt .Sprintf ("/%s/%s/branches/delete?name=%s" , url .PathEscape (owner ), url .PathEscape (repo ), url .QueryEscape (branch )), map [string ]string {
554
+ "_csrf" : csrf ,
555
+ })
556
+ ctx .Session .MakeRequest (t , req , http .StatusOK )
557
+ }
558
+ }
0 commit comments