1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-07-02 16:38:34 +00:00
forgejo/tests/integration/api_repo_pulls_test.go
ThomasBoom89 6cac7702e9 fix(api): encode empty requested reviewers as an empty array (#7355)
- Always initialize `RequestedReviewers` and `RequestedReviewersTeams`, this avoids the JSON encoder from encoding it to the zero value `null` and instead return a empty array.
- Resolves #4108
- Integration test added.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7355
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: ThomasBoom89 <thomasboom89@noreply.codeberg.org>
Co-committed-by: ThomasBoom89 <thomasboom89@noreply.codeberg.org>
2025-03-28 11:50:05 +00:00

34 lines
889 B
Go

// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package integration
import (
"fmt"
"net/http"
"testing"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/tests"
"github.com/stretchr/testify/assert"
)
func TestAPIRepoPulls(t *testing.T) {
defer tests.PrepareTestEnv(t)()
// repo = user2/repo1
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
// issue id without assigned review member or review team
issueID := 5
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d", repo.OwnerName, repo.Name, issueID))
res := MakeRequest(t, req, http.StatusOK)
var pr *api.PullRequest
DecodeJSON(t, res, &pr)
assert.NotNil(t, pr.RequestedReviewers)
assert.NotNil(t, pr.RequestedReviewersTeams)
}