summaryrefslogtreecommitdiffstats
path: root/modules/structs/issue_test.go
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2022-11-16 19:14:58 +0800
committerGitHub <noreply@github.com>2022-11-16 19:14:58 +0800
commit92dd24716d22bbb849365605a13b94e8897d06fd (patch)
treecb668fd927ec916903e7748a7ae891f94c0c19c7 /modules/structs/issue_test.go
parentf311d15a0ba6e4864d7e5dea83364f93e8eadca4 (diff)
downloadgitea-92dd24716d22bbb849365605a13b94e8897d06fd.tar.gz
gitea-92dd24716d22bbb849365605a13b94e8897d06fd.zip
Ignore issue template with a special name (#21830)
A file in `ISSUE_TEMPLATE` with the name `config.yml` shouldn't be treated as a YAML template, it's for [configuring the template chooser](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser). The old code tried to ignore the file, but it didn't work, caused by #20987. That's why the warning is displayed: <img width="415" alt="image" src="https://user-images.githubusercontent.com/9418365/202094067-804c42fe-0e9e-4fc5-bf01-d95fa336f54f.png"> Note that this PR is not an implementation of `config.yml`, there will be another one to do it.
Diffstat (limited to 'modules/structs/issue_test.go')
-rw-r--r--modules/structs/issue_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/modules/structs/issue_test.go b/modules/structs/issue_test.go
new file mode 100644
index 0000000000..5312585d0f
--- /dev/null
+++ b/modules/structs/issue_test.go
@@ -0,0 +1,43 @@
+// Copyright 2022 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package structs
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestIssueTemplate_Type(t *testing.T) {
+ tests := []struct {
+ fileName string
+ want IssueTemplateType
+ }{
+ {
+ fileName: ".gitea/ISSUE_TEMPLATE/bug_report.yaml",
+ want: IssueTemplateTypeYaml,
+ },
+ {
+ fileName: ".gitea/ISSUE_TEMPLATE/bug_report.md",
+ want: IssueTemplateTypeMarkdown,
+ },
+ {
+ fileName: ".gitea/ISSUE_TEMPLATE/bug_report.txt",
+ want: "",
+ },
+ {
+ fileName: ".gitea/ISSUE_TEMPLATE/config.yaml",
+ want: "",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.fileName, func(t *testing.T) {
+ it := IssueTemplate{
+ FileName: tt.fileName,
+ }
+ assert.Equal(t, tt.want, it.Type())
+ })
+ }
+}