mirror of https://github.com/go-gitea/gitea.git
prevent empty review comment (#4632)
* prevent empty review comment This would only require a comment for rejection and comment * add tests * add commentpull/4628/head^2
parent
59b10e66f7
commit
0df7cab4fb
@ -0,0 +1,41 @@
|
||||
// Copyright 2018 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 auth
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSubmitReviewForm_IsEmpty(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
form SubmitReviewForm
|
||||
expected bool
|
||||
}{
|
||||
// Approved PR with a comment shouldn't count as empty
|
||||
{SubmitReviewForm{Type: "approve", Content: "Awesome"}, false},
|
||||
|
||||
// Approved PR without a comment shouldn't count as empty
|
||||
{SubmitReviewForm{Type: "approve", Content: ""}, false},
|
||||
|
||||
// Rejected PR without a comment should count as empty
|
||||
{SubmitReviewForm{Type: "reject", Content: ""}, true},
|
||||
|
||||
// Rejected PR with a comment shouldn't count as empty
|
||||
{SubmitReviewForm{Type: "reject", Content: "Awesome"}, false},
|
||||
|
||||
// Comment review on a PR with a comment shouldn't count as empty
|
||||
{SubmitReviewForm{Type: "comment", Content: "Awesome"}, false},
|
||||
|
||||
// Comment review on a PR without a comment should count as empty
|
||||
{SubmitReviewForm{Type: "comment", Content: ""}, true},
|
||||
}
|
||||
|
||||
for _, v := range cases {
|
||||
assert.Equal(t, v.expected, v.form.HasEmptyContent())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue