mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
test(pr): follow the pr changes in the Gitea lifecycle test and polish flag help
The disposable-Gitea lifecycle test expects pr checkout to name the branch after the head branch and to fetch quietly, and ✓ feedback only on terminals. The review flags name their file and commit values, and pr edit gets a short Short with the editable fields in its Long text. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
3 files changed
+8
-7
No files matched your search
@@ -19,7 +19,8 @@ func (a *application) pullEditCommand() *cobra.Command {
|
|||||||
var draft, ready, maintainer, useEditor, removeMilestone bool
|
var draft, ready, maintainer, useEditor, removeMilestone bool
|
||||||
var metadata metadataFlags
|
var metadata metadataFlags
|
||||||
var reviewers services.ReviewRequestChanges
|
var reviewers services.ReviewRequestChanges
|
||||||
cmd := &cobra.Command{Use: "edit [<number> | <url> | <branch>]", Short: "Edit a pull request: title, body, base, reviewers, labels, assignees, milestone, due date", Annotations: pullArgumentsAnnotation(nil), Args: usageArgs(cobra.MaximumNArgs(1)), RunE: func(cmd *cobra.Command, args []string) (runErr error) {
|
cmd := &cobra.Command{Use: "edit [<number> | <url> | <branch>]", Short: "Edit a pull request", Long: `Edit the title, body, base branch, reviewers, labels, assignees, milestone or due date of a
|
||||||
|
pull request, or mark it as a draft or ready for review.`, Annotations: pullArgumentsAnnotation(nil), Args: usageArgs(cobra.MaximumNArgs(1)), RunE: func(cmd *cobra.Command, args []string) (runErr error) {
|
||||||
var editorDraft terminal.Draft
|
var editorDraft terminal.Draft
|
||||||
defer finishDraft(&editorDraft, &runErr)
|
defer finishDraft(&editorDraft, &runErr)
|
||||||
if err := validateBodySources(cmd); err != nil {
|
if err := validateBodySources(cmd); err != nil {
|
||||||
|
|||||||
@@ -147,8 +147,8 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
|
|||||||
diagnostics.Reset()
|
diagnostics.Reset()
|
||||||
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", n, "-R", repo.FullName, "--cwd", workingTree, "--no-input", "--json"}))
|
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", n, "-R", repo.FullName, "--cwd", workingTree, "--no-input", "--json"}))
|
||||||
require.NoError(t, json.Unmarshal(out.Bytes(), &checkout))
|
require.NoError(t, json.Unmarshal(out.Bytes(), &checkout))
|
||||||
require.Contains(t, diagnostics.String(), "FETCH_HEAD")
|
require.Empty(t, diagnostics.String(), "checkout fetches quietly")
|
||||||
require.Equal(t, "pr/"+n, checkout.Branch)
|
require.Equal(t, "feature", checkout.Branch, "the local branch takes the head branch name")
|
||||||
require.Equal(t, head.Head.SHA, checkout.Commit)
|
require.Equal(t, head.Head.SHA, checkout.Commit)
|
||||||
actual, err := runner.Output(context.Background(), workingTree, false, "rev-parse", "HEAD")
|
actual, err := runner.Output(context.Background(), workingTree, false, "rev-parse", "HEAD")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -233,7 +233,7 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
|
|||||||
diagnostics.Reset()
|
diagnostics.Reset()
|
||||||
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "review", "resolve", commentID, "-R", repo.FullName}))
|
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "review", "resolve", commentID, "-R", repo.FullName}))
|
||||||
require.Empty(t, out.String())
|
require.Empty(t, out.String())
|
||||||
require.Contains(t, diagnostics.String(), "resolved")
|
require.Empty(t, diagnostics.String(), "feedback is for terminals")
|
||||||
require.NoError(t, json.Unmarshal(execute("pr", "review", "comments", n, "-R", repo.FullName, "--review", fmt.Sprint(review.ID), "--json"), &comments))
|
require.NoError(t, json.Unmarshal(execute("pr", "review", "comments", n, "-R", repo.FullName, "--review", fmt.Sprint(review.ID), "--json"), &comments))
|
||||||
require.NotEmpty(t, comments[0].Resolver)
|
require.NotEmpty(t, comments[0].Resolver)
|
||||||
out.Reset()
|
out.Reset()
|
||||||
@@ -254,7 +254,7 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
|
|||||||
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "review", "delete", n, fmt.Sprint(submitted.ID), "-R", repo.FullName, "--yes"}))
|
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "review", "delete", n, fmt.Sprint(submitted.ID), "-R", repo.FullName, "--yes"}))
|
||||||
verifyEditorSubmission(t, deps, repo.FullName, n, true)
|
verifyEditorSubmission(t, deps, repo.FullName, n, true)
|
||||||
require.Empty(t, out.String())
|
require.Empty(t, out.String())
|
||||||
require.Contains(t, diagnostics.String(), "Deleted review")
|
require.Empty(t, diagnostics.String(), "feedback is for terminals")
|
||||||
if reviewerTokenFile := os.Getenv("GITEA_TEA_TEST_REVIEWER_TOKEN_FILE"); reviewerTokenFile != "" {
|
if reviewerTokenFile := os.Getenv("GITEA_TEA_TEST_REVIEWER_TOKEN_FILE"); reviewerTokenFile != "" {
|
||||||
reviewerDeps := deps
|
reviewerDeps := deps
|
||||||
reviewerDeps.Getenv = gitea.env(readTokenFile(t, reviewerTokenFile))
|
reviewerDeps.Getenv = gitea.env(readTokenFile(t, reviewerTokenFile))
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ func (a *application) reviewCreateCommand(use, short string) *cobra.Command {
|
|||||||
cmd.Flags().StringVarP(&body, "body", "b", "", "Review body")
|
cmd.Flags().StringVarP(&body, "body", "b", "", "Review body")
|
||||||
cmd.Flags().StringVarP(&file, "body-file", "F", "", "Read the body from `file`, or - for stdin")
|
cmd.Flags().StringVarP(&file, "body-file", "F", "", "Read the body from `file`, or - for stdin")
|
||||||
cmd.Flags().BoolVarP(&useEditor, "editor", "e", false, "Write the body in your editor")
|
cmd.Flags().BoolVarP(&useEditor, "editor", "e", false, "Write the body in your editor")
|
||||||
cmd.Flags().StringVar(&commentsFile, "comments-file", "", "JSON array of inline comments: path, body, and new_position or old_position")
|
cmd.Flags().StringVar(&commentsFile, "comments-file", "", "Read inline comments from a JSON `file`: an array of path, body, and new_position or old_position")
|
||||||
cmd.Flags().StringVar(&commit, "commit", "", "Commit to review (default: the head of the pull request)")
|
cmd.Flags().StringVar(&commit, "commit", "", "Commit `sha` to review (default: the head of the pull request)")
|
||||||
cmd.ValidArgsFunction = a.completePulls("open")
|
cmd.ValidArgsFunction = a.completePulls("open")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user