gitea源码

repo_form_test.go 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package forms
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestSubmitReviewForm_IsEmpty(t *testing.T) {
  9. cases := []struct {
  10. form SubmitReviewForm
  11. expected bool
  12. }{
  13. // Approved PR with a comment shouldn't count as empty
  14. {SubmitReviewForm{Type: "approve", Content: "Awesome"}, false},
  15. // Approved PR without a comment shouldn't count as empty
  16. {SubmitReviewForm{Type: "approve", Content: ""}, false},
  17. // Rejected PR without a comment should count as empty
  18. {SubmitReviewForm{Type: "reject", Content: ""}, true},
  19. // Rejected PR with a comment shouldn't count as empty
  20. {SubmitReviewForm{Type: "reject", Content: "Awesome"}, false},
  21. // Comment review on a PR with a comment shouldn't count as empty
  22. {SubmitReviewForm{Type: "comment", Content: "Awesome"}, false},
  23. // Comment review on a PR without a comment should count as empty
  24. {SubmitReviewForm{Type: "comment", Content: ""}, true},
  25. }
  26. for _, v := range cases {
  27. assert.Equal(t, v.expected, v.form.HasEmptyContent())
  28. }
  29. }