gitea/services/forms/repo_form_test.go
YaFou e947f309b1
Add API routes to lock and unlock issues (#34165)
This pull request adds a GitHub-compatible API endpoint to lock and
unlock an issue.

The following routes exist now:
- `PUT /api/v1/repos/{owner}/{repo}/issues/{id}/lock` to lock an issue
- `DELETE /api/v1/repos/{owner}/{repo}/issues/{id}/lock` to unlock an issue

Fixes #33677
Fixes #20012

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-21 00:43:43 +00:00

40 lines
1.1 KiB
Go

// Copyright 2018 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package forms
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())
}
}