diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-03-03 06:31:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-02 22:31:55 +0000 |
commit | 5abe1c52de533b52725b1e584db9fea6fb1b39ab (patch) | |
tree | 1cd49bc1a609bb919c70d6bc30727c524c3e6105 /modules/convert/pull_test.go | |
parent | 22b750702408a39a524e011b729d0e0befb30e16 (diff) | |
download | gitea-5abe1c52de533b52725b1e584db9fea6fb1b39ab.tar.gz gitea-5abe1c52de533b52725b1e584db9fea6fb1b39ab.zip |
Display pull request head branch even the branch deleted or repository deleted (#10413)
* Display pull request head branch even the branch deleted or repository deleted
* Merge getHeadRepo/loadHeadRepo and getBaseRepo/loadBaseRepo on pull and fill repo when pr.Issue.Repo is available
* retrieve sha from pull head when pull request branch deleted and fix tests
* Fix test
* Ensure MustHeadRepoName returns empty string if no head repo
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'modules/convert/pull_test.go')
-rw-r--r-- | modules/convert/pull_test.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/convert/pull_test.go b/modules/convert/pull_test.go index fe82a61bd4..b78bbe87c9 100644 --- a/modules/convert/pull_test.go +++ b/modules/convert/pull_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) @@ -15,12 +16,19 @@ import ( func TestPullRequest_APIFormat(t *testing.T) { //with HeadRepo assert.NoError(t, models.PrepareTestDatabase()) + headRepo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) pr := models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 1}).(*models.PullRequest) assert.NoError(t, pr.LoadAttributes()) assert.NoError(t, pr.LoadIssue()) apiPullRequest := ToAPIPullRequest(pr) assert.NotNil(t, apiPullRequest) - assert.Nil(t, apiPullRequest.Head) + assert.EqualValues(t, &structs.PRBranchInfo{ + Name: "branch1", + Ref: "refs/pull/2/head", + Sha: "4a357436d925b5c974181ff12a994538ddc5a269", + RepoID: 1, + Repository: headRepo.APIFormat(models.AccessModeNone), + }, apiPullRequest.Head) //withOut HeadRepo pr = models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 1}).(*models.PullRequest) |