mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
test(pr): drop cases that repeat covered pr list, merge, review and diff paths
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
4 files changed
+5
-27
No files matched your search
@@ -60,19 +60,7 @@ func mergeServer(t *testing.T, pull string, payload *map[string]any) http.Handle
|
|||||||
|
|
||||||
const openPull = `{"number":3,"title":"Add login","state":"open","base":{"ref":"main"},"head":{"ref":"feature","sha":"abc123","repo":{"full_name":"alice/project","permissions":{"push":true}}}}`
|
const openPull = `{"number":3,"title":"Add login","state":"open","base":{"ref":"main"},"head":{"ref":"feature","sha":"abc123","repo":{"full_name":"alice/project","permissions":{"push":true}}}}`
|
||||||
|
|
||||||
func TestPullMergeUsesTheRepositoryDefaults(t *testing.T) {
|
func TestPullMergeUsesTheRepositoryDefaultsAndKeepsTheLocalBranch(t *testing.T) {
|
||||||
var payload map[string]any
|
|
||||||
server := newAuthenticatedServer(mergeServer(t, openPull, &payload))
|
|
||||||
defer server.Close()
|
|
||||||
deps, out, diagnostics := serverDeps(t, server.URL)
|
|
||||||
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "merge", "3", "-R", "alice/project", "--yes"}))
|
|
||||||
require.Equal(t, "squash", payload["Do"])
|
|
||||||
require.Equal(t, true, payload["delete_branch_after_merge"])
|
|
||||||
require.Empty(t, out.String())
|
|
||||||
require.Empty(t, diagnostics.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPullMergeKeepsTheLocalBranchWithoutTheFlag(t *testing.T) {
|
|
||||||
for _, tc := range []struct {
|
for _, tc := range []struct {
|
||||||
name string
|
name string
|
||||||
flags []string
|
flags []string
|
||||||
@@ -85,11 +73,14 @@ func TestPullMergeKeepsTheLocalBranchWithoutTheFlag(t *testing.T) {
|
|||||||
var payload map[string]any
|
var payload map[string]any
|
||||||
server := newAuthenticatedServer(mergeServer(t, openPull, &payload))
|
server := newAuthenticatedServer(mergeServer(t, openPull, &payload))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
deps, _, _ := serverDeps(t, server.URL)
|
deps, out, diagnostics := serverDeps(t, server.URL)
|
||||||
fake := &fakeGit{results: map[string]string{"symbolic-ref --short HEAD": "feature"}}
|
fake := &fakeGit{results: map[string]string{"symbolic-ref --short HEAD": "feature"}}
|
||||||
deps.Git = fake
|
deps.Git = fake
|
||||||
require.NoError(t, Execute(context.Background(), deps, append([]string{"pr", "merge", "3", "-R", "alice/project", "--yes"}, tc.flags...)))
|
require.NoError(t, Execute(context.Background(), deps, append([]string{"pr", "merge", "3", "-R", "alice/project", "--yes"}, tc.flags...)))
|
||||||
|
require.Equal(t, "squash", payload["Do"])
|
||||||
require.Equal(t, true, payload["delete_branch_after_merge"])
|
require.Equal(t, true, payload["delete_branch_after_merge"])
|
||||||
|
require.Empty(t, out.String())
|
||||||
|
require.Empty(t, diagnostics.String())
|
||||||
require.Equal(t, tc.local, slices.Contains(fake.calls, "rev-parse --verify refs/heads/feature^{commit}"), fake.calls)
|
require.Equal(t, tc.local, slices.Contains(fake.calls, "rev-parse --verify refs/heads/feature^{commit}"), fake.calls)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ func TestPullDiffStripsTerminalControlsOnlyOnATerminal(t *testing.T) {
|
|||||||
{true, nil, "1", "+hello ]0;PWNED [31mred[0m\n-old\tline\n"},
|
{true, nil, "1", "+hello ]0;PWNED [31mred[0m\n-old\tline\n"},
|
||||||
{true, nil, "", "\x1b[32m+hello ]0;PWNED [31mred[0m\x1b[0m\n\x1b[31m-old\tline\x1b[0m\n"},
|
{true, nil, "", "\x1b[32m+hello ]0;PWNED [31mred[0m\x1b[0m\n\x1b[31m-old\tline\x1b[0m\n"},
|
||||||
{false, []string{"--color", "always"}, "", "\x1b[32m+hello ]0;PWNED [31mred[0m\x1b[0m\n\x1b[31m-old\tline\x1b[0m\n"},
|
{false, []string{"--color", "always"}, "", "\x1b[32m+hello ]0;PWNED [31mred[0m\x1b[0m\n\x1b[31m-old\tline\x1b[0m\n"},
|
||||||
{true, []string{"--color", "never"}, "", "+hello ]0;PWNED [31mred[0m\n-old\tline\n"},
|
|
||||||
} {
|
} {
|
||||||
deps, out, _ := serverDeps(t, server.URL)
|
deps, out, _ := serverDeps(t, server.URL)
|
||||||
deps.Getenv = serverEnv(server.URL, map[string]string{"NO_COLOR": tc.color})
|
deps.Getenv = serverEnv(server.URL, map[string]string{"NO_COLOR": tc.color})
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ func TestReviewTypeFlags(t *testing.T) {
|
|||||||
{[]string{"-c", "-b", "Nit"}, "COMMENT", "Nit"},
|
{[]string{"-c", "-b", "Nit"}, "COMMENT", "Nit"},
|
||||||
{[]string{"--pending", "-b", "Draft"}, "PENDING", "Draft"},
|
{[]string{"--pending", "-b", "Draft"}, "PENDING", "Draft"},
|
||||||
{[]string{"--event", "approve"}, "APPROVED", ""},
|
{[]string{"--event", "approve"}, "APPROVED", ""},
|
||||||
{[]string{"--event", "APPROVED"}, "APPROVED", ""},
|
|
||||||
{[]string{"--event", "request_changes", "-b", "x"}, "REQUEST_CHANGES", "x"},
|
{[]string{"--event", "request_changes", "-b", "x"}, "REQUEST_CHANGES", "x"},
|
||||||
{[]string{"--event", "Comment", "-b", "x"}, "COMMENT", "x"},
|
{[]string{"--event", "Comment", "-b", "x"}, "COMMENT", "x"},
|
||||||
} {
|
} {
|
||||||
|
|||||||
@@ -14,17 +14,6 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPullListExplicitState(t *testing.T) {
|
|
||||||
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
require.Equal(t, "closed", r.URL.Query().Get("state"))
|
|
||||||
_, _ = w.Write([]byte(`[]`))
|
|
||||||
}))
|
|
||||||
defer server.Close()
|
|
||||||
deps, out, _ := serverDeps(t, server.URL)
|
|
||||||
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "list", "--state=closed", "-R", "alice/project", "--json"}))
|
|
||||||
require.JSONEq(t, `[]`, out.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
// pullListServer lists the pull requests of alice/project: #17 from bob's fork, #15 a draft, #14
|
// pullListServer lists the pull requests of alice/project: #17 from bob's fork, #15 a draft, #14
|
||||||
// merged and #16 closed, with the total count Gitea reports.
|
// merged and #16 closed, with the total count Gitea reports.
|
||||||
func pullListServer(t *testing.T, states *[]string) *http.Server {
|
func pullListServer(t *testing.T, states *[]string) *http.Server {
|
||||||
|
|||||||
Reference in new issue
Block a user