diff options
Diffstat (limited to 'modules/auth/repo_form_test.go')
-rw-r--r-- | modules/auth/repo_form_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/auth/repo_form_test.go b/modules/auth/repo_form_test.go index f6223d6c8a..a3369b006e 100644 --- a/modules/auth/repo_form_test.go +++ b/modules/auth/repo_form_test.go @@ -7,6 +7,7 @@ package auth import ( "testing" + "code.gitea.io/gitea/modules/setting" "github.com/stretchr/testify/assert" ) @@ -39,3 +40,27 @@ func TestSubmitReviewForm_IsEmpty(t *testing.T) { assert.Equal(t, v.expected, v.form.HasEmptyContent()) } } + +func TestIssueLock_HasValidReason(t *testing.T) { + + // Init settings + _ = setting.Repository + + cases := []struct { + form IssueLockForm + expected bool + }{ + {IssueLockForm{""}, true}, // an empty reason is accepted + {IssueLockForm{"Off-topic"}, true}, + {IssueLockForm{"Too heated"}, true}, + {IssueLockForm{"Spam"}, true}, + {IssueLockForm{"Resolved"}, true}, + + {IssueLockForm{"ZZZZ"}, false}, + {IssueLockForm{"I want to lock this issue"}, false}, + } + + for _, v := range cases { + assert.Equal(t, v.expected, v.form.HasValidReason()) + } +} |