mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
test(app): drop completion and table cases other tests already cover
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
4 files changed
+2
-36
No files matched your search
@@ -161,7 +161,6 @@ func TestOfflineCompletions(t *testing.T) {
|
|||||||
"for-each-ref --format=%(refname:short) refs/heads": "main\nfeature/login\n",
|
"for-each-ref --format=%(refname:short) refs/heads": "main\nfeature/login\n",
|
||||||
}}
|
}}
|
||||||
configureAccounts(t, deps, "https://gitea.example.com", "alice", "alice", "bob")
|
configureAccounts(t, deps, "https://gitea.example.com", "alice", "alice", "bob")
|
||||||
require.NoError(t, Execute(context.Background(), deps, []string{"alias", "set", "co", "pr checkout"}))
|
|
||||||
for args, want := range map[string][]string{
|
for args, want := range map[string][]string{
|
||||||
"--host ": {"https://gitea.example.com\talice, bob"},
|
"--host ": {"https://gitea.example.com\talice, bob"},
|
||||||
"--user ": {"alice\thttps://gitea.example.com (active)", "bob\thttps://gitea.example.com"},
|
"--user ": {"alice\thttps://gitea.example.com (active)", "bob\thttps://gitea.example.com"},
|
||||||
@@ -180,9 +179,6 @@ func TestOfflineCompletions(t *testing.T) {
|
|||||||
prefix string
|
prefix string
|
||||||
want []string
|
want []string
|
||||||
}{
|
}{
|
||||||
{a.completeAliases, nil, "", []string{"co\tpr checkout"}},
|
|
||||||
{a.completeConfig, nil, "git", []string{"git_protocol"}},
|
|
||||||
{a.completeConfig, []string{"color"}, "a", []string{"auto", "always"}},
|
|
||||||
{a.completeConfig, []string{"default_host"}, "", []string{"https://gitea.example.com\talice, bob"}},
|
{a.completeConfig, []string{"default_host"}, "", []string{"https://gitea.example.com\talice, bob"}},
|
||||||
{a.completeConfig, []string{"color", "auto"}, "", []string{}},
|
{a.completeConfig, []string{"color", "auto"}, "", []string{}},
|
||||||
{a.completeLocalBranches, nil, "f", []string{"feature/login\tlocal branch"}},
|
{a.completeLocalBranches, nil, "f", []string{"feature/login\tlocal branch"}},
|
||||||
|
|||||||
@@ -266,15 +266,13 @@ func TestCommandHelpShowsRelevantFlagsOnly(t *testing.T) {
|
|||||||
out.Reset()
|
out.Reset()
|
||||||
require.NoError(t, Execute(context.Background(), deps, []string{"label", "list", "--help"}))
|
require.NoError(t, Execute(context.Background(), deps, []string{"label", "list", "--help"}))
|
||||||
require.Contains(t, out.String(), "\nFLAGS\n -L, --limit int Maximum number of results (1..1000) (default 30)\n --org organization ")
|
require.Contains(t, out.String(), "\nFLAGS\n -L, --limit int Maximum number of results (1..1000) (default 30)\n --org organization ")
|
||||||
for _, args := range [][]string{{"version", "--help"}, {"alias", "list", "--help"}, {"auth", "status", "--help"}} {
|
for _, args := range [][]string{{"alias", "list", "--help"}, {"auth", "status", "--help"}, {"version", "--help"}} {
|
||||||
out.Reset()
|
out.Reset()
|
||||||
require.NoError(t, Execute(context.Background(), deps, args))
|
require.NoError(t, Execute(context.Background(), deps, args))
|
||||||
require.NotContains(t, out.String(), "--repo", args)
|
require.NotContains(t, out.String(), "--repo", args)
|
||||||
require.Contains(t, out.String(), globalFlagsLine, args)
|
require.Contains(t, out.String(), globalFlagsLine, args)
|
||||||
}
|
}
|
||||||
out.Reset()
|
require.NotContains(t, out.String(), "--json fields", "version prints text")
|
||||||
require.NoError(t, Execute(context.Background(), deps, []string{"version", "--help"}))
|
|
||||||
require.NotContains(t, out.String(), "--json fields")
|
|
||||||
out.Reset()
|
out.Reset()
|
||||||
require.NoError(t, Execute(context.Background(), deps, []string{"issue", "--help"}))
|
require.NoError(t, Execute(context.Background(), deps, []string{"issue", "--help"}))
|
||||||
require.Contains(t, out.String(), "\nUSAGE\n tea issue <command> [flags]\n\nAVAILABLE COMMANDS\n attachment: ")
|
require.Contains(t, out.String(), "\nUSAGE\n tea issue <command> [flags]\n\nAVAILABLE COMMANDS\n attachment: ")
|
||||||
|
|||||||
@@ -282,9 +282,7 @@ func TestPlatformCommandsComplete(t *testing.T) {
|
|||||||
{[]string{"alias", "delete", ""}, []string{"il\tissue list"}},
|
{[]string{"alias", "delete", ""}, []string{"il\tissue list"}},
|
||||||
{[]string{"config", "get", "hyp"}, []string{"hyperlinks"}},
|
{[]string{"config", "get", "hyp"}, []string{"hyperlinks"}},
|
||||||
{[]string{"config", "set", "hyperlinks", ""}, []string{"auto", "always", "never"}},
|
{[]string{"config", "set", "hyperlinks", ""}, []string{"auto", "always", "never"}},
|
||||||
{[]string{"config", "set", "markdown", ""}, []string{"auto", "raw"}},
|
|
||||||
{[]string{"auth", "switch", ""}, []string{"alice\t" + server.URL + " (active)", "bob\t" + server.URL}},
|
{[]string{"auth", "switch", ""}, []string{"alice\t" + server.URL + " (active)", "bob\t" + server.URL}},
|
||||||
{[]string{"auth", "logout", "b"}, []string{"bob\t" + server.URL}},
|
|
||||||
{[]string{"auth", "login", "--credential-store", ""}, []string{"keyring", "file"}},
|
{[]string{"auth", "login", "--credential-store", ""}, []string{"keyring", "file"}},
|
||||||
{[]string{"auth", "login", "--scopes", "read:repository,write:re"}, []string{"read:repository,write:repository"}},
|
{[]string{"auth", "login", "--scopes", "read:repository,write:re"}, []string{"read:repository,write:repository"}},
|
||||||
{[]string{"notification", "list", "--type", ""}, []string{"issue", "pull", "commit", "repository"}},
|
{[]string{"notification", "list", "--type", ""}, []string{"issue", "pull", "commit", "repository"}},
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import (
|
|||||||
|
|
||||||
"gitea.dev/tea/internal/settings"
|
"gitea.dev/tea/internal/settings"
|
||||||
"gitea.dev/tea/internal/terminal"
|
"gitea.dev/tea/internal/terminal"
|
||||||
"github.com/mattn/go-runewidth"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -217,31 +216,6 @@ func TestListsHintWhenMorePagesExist(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListsFitTheTerminalAndSplitWhenPiped(t *testing.T) {
|
|
||||||
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
|
||||||
_, _ = w.Write([]byte(`[{"number":6,"title":"A very long issue title that keeps going and going to see how list output handles wrapping","state":"open","user":{"login":"alice"}},` +
|
|
||||||
`{"number":5,"title":"支持中文路径 (support CJK paths)","state":"open","user":{"login":""}}]`))
|
|
||||||
}))
|
|
||||||
defer server.Close()
|
|
||||||
deps, out, _ := serverDeps(t, server.URL)
|
|
||||||
args := []string{"issue", "list", "-R", "alice/project"}
|
|
||||||
require.NoError(t, Execute(context.Background(), deps, args))
|
|
||||||
require.Equal(t, "6\tA very long issue title that keeps going and going to see how list output handles wrapping\t\topen\tissue\talice\t\n"+
|
|
||||||
"5\t支持中文路径 (support CJK paths)\t\topen\tissue\t\t\n", out.String())
|
|
||||||
|
|
||||||
out.Reset()
|
|
||||||
deps.Streams.OutTTY, deps.Streams.Width = true, 50
|
|
||||||
deps.Getenv = serverEnv(server.URL, map[string]string{"NO_COLOR": "1"})
|
|
||||||
require.NoError(t, Execute(context.Background(), deps, args))
|
|
||||||
require.Equal(t, "Showing 2 of 2 open issues in alice/project\n\n"+
|
|
||||||
"ID TITLE LABELS AUTHOR UPDATED\n"+
|
|
||||||
"#6 A very long issue ti… alice\n"+
|
|
||||||
"#5 支持中文路径 (suppor…\n", stripLinks(out.String()))
|
|
||||||
for _, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
|
||||||
require.LessOrEqual(t, runewidth.StringWidth(stripLinks(line)), 50, line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// stripLinks removes OSC 8 hyperlinks from rendered output.
|
// stripLinks removes OSC 8 hyperlinks from rendered output.
|
||||||
func stripLinks(s string) string {
|
func stripLinks(s string) string {
|
||||||
for {
|
for {
|
||||||
|
|||||||
Reference in new issue
Block a user