You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB

  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package auth
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestSubmitReviewForm_IsEmpty(t *testing.T) {
  10. cases := []struct {
  11. form SubmitReviewForm
  12. expected bool
  13. }{
  14. // Approved PR with a comment shouldn't count as empty
  15. {SubmitReviewForm{Type: "approve", Content: "Awesome"}, false},
  16. // Approved PR without a comment shouldn't count as empty
  17. {SubmitReviewForm{Type: "approve", Content: ""}, false},
  18. // Rejected PR without a comment should count as empty
  19. {SubmitReviewForm{Type: "reject", Content: ""}, true},
  20. // Rejected PR with a comment shouldn't count as empty
  21. {SubmitReviewForm{Type: "reject", Content: "Awesome"}, false},
  22. // Comment review on a PR with a comment shouldn't count as empty
  23. {SubmitReviewForm{Type: "comment", Content: "Awesome"}, false},
  24. // Comment review on a PR without a comment should count as empty
  25. {SubmitReviewForm{Type: "comment", Content: ""}, true},
  26. }
  27. for _, v := range cases {
  28. assert.Equal(t, v.expected, v.form.HasEmptyContent())
  29. }
  30. }