diff options
author | JakobDev <jakobdev@gmx.de> | 2023-03-28 20:22:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-28 14:22:07 -0400 |
commit | f384b13f1cd44be3a87df5553a0099390dacd010 (patch) | |
tree | 08b2744df3a8792ef2f50e4d559d55e4a349c198 /tests/integration/api_issue_config_test.go | |
parent | 5cd1d6c93ba9b8399f826e671b8940eb5294b872 (diff) | |
download | gitea-f384b13f1cd44be3a87df5553a0099390dacd010.tar.gz gitea-f384b13f1cd44be3a87df5553a0099390dacd010.zip |
Implement Issue Config (#20956)
Closes #20955
This PR adds the possibility to disable blank Issues, when the Repo has
templates. This can be done by creating the file
`.gitea/issue_config.yaml` with the content `blank_issues_enabled` in
the Repo.
Diffstat (limited to 'tests/integration/api_issue_config_test.go')
-rw-r--r-- | tests/integration/api_issue_config_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/integration/api_issue_config_test.go b/tests/integration/api_issue_config_test.go new file mode 100644 index 0000000000..b9b3765c4e --- /dev/null +++ b/tests/integration/api_issue_config_test.go @@ -0,0 +1,52 @@ +// Copyright 2023 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" + user_model "code.gitea.io/gitea/models/user" + api "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/tests" + + "github.com/stretchr/testify/assert" +) + +func TestAPIReposGetDefaultIssueConfig(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) + owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) + + urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issue_config", owner.Name, repo.Name) + req := NewRequest(t, "GET", urlStr) + resp := MakeRequest(t, req, http.StatusOK) + + var issueConfig api.IssueConfig + DecodeJSON(t, resp, &issueConfig) + + assert.True(t, issueConfig.BlankIssuesEnabled) + assert.Equal(t, issueConfig.ContactLinks, make([]api.IssueConfigContactLink, 0)) +} + +func TestAPIReposValidateDefaultIssueConfig(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) + owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) + + urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issue_config/validate", owner.Name, repo.Name) + req := NewRequest(t, "GET", urlStr) + resp := MakeRequest(t, req, http.StatusOK) + + var issueConfigValidation api.IssueConfigValidation + DecodeJSON(t, resp, &issueConfigValidation) + + assert.True(t, issueConfigValidation.Valid) + assert.Equal(t, issueConfigValidation.Message, "") +} |