mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
- `internal/terminal`: streams and the prompting policy, interactive forms (issue, PR, review, merge, milestone), editor / pager / browser launching, JSON and `--jq` output. - An aligned table renderer and a record renderer for human output; both strip control and escape characters from server-supplied text so titles and bodies cannot inject terminal sequences. Reviewed-on: https://gitea.com/gitea/tea/pulls/1124 Reviewed-by: TheFox0x7 <95654+thefox0x7@noreply.gitea.com>
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package terminal
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCreateReviewAbortsWhenDiffReviewFails(t *testing.T) {
|
|
failure := errors.New("editor failed")
|
|
p, _ := accessiblePrompter(t, "y\n1\n")
|
|
_, err := p.CreateReview(context.Background(), ReviewFormChoices{
|
|
ReviewDiff: func(context.Context) ([]ReviewCommentDraft, error) { return nil, failure },
|
|
})
|
|
require.ErrorIs(t, err, failure)
|
|
}
|
|
|
|
func TestReviewFormRequiresCommentOnlyWhenRequestingChanges(t *testing.T) {
|
|
p, rendered := accessiblePrompter(t, "3\n")
|
|
_, err := p.CreateReview(context.Background(), ReviewFormChoices{})
|
|
require.NoError(t, err)
|
|
require.Contains(t, rendered.String(), "Concluding comment(markdown):")
|
|
require.NotContains(t, rendered.String(), "(required)")
|
|
|
|
p, rendered = accessiblePrompter(t, "2\n")
|
|
_, err = p.CreateReview(context.Background(), ReviewFormChoices{})
|
|
require.ErrorContains(t, err, "concluding comment cannot be empty")
|
|
require.Contains(t, rendered.String(), "Concluding comment(markdown) (required):")
|
|
}
|