mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
Drop additions that the UX plan does not ask for: - the interactive label edit form; label edit now requires a flag - label clone and the skip mode of label creation it needed - repo rename rewriting the Git remote or tea.repository; it now warns that the remote still points to the old name - the extra "source" remote on clones of pull mirrors - run artifact download, which duplicates run download --zip - 256-color and 24-bit label swatches; colors stay ANSI 16 - config list --show-source (config get keeps it) - the membership and access GETs before team member/repo add and remove; Gitea's PUT and DELETE are idempotent label edit/delete keep --by-name: it is the only way to address a label whose name is a number that is also another label's ID. Signed-off-by: bircni <bircni@icloud.com>
69 lines
2.5 KiB
Go
69 lines
2.5 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package app
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"gitea.dev/tea/internal/clierr"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestManWritesSelectedCommandWithoutReplacingFiles(t *testing.T) {
|
|
deps, out, _ := testDeps(t)
|
|
path := filepath.Join(t.TempDir(), "checkout.1")
|
|
args := []string{"man", "pr", "checkout", "--output-file", path}
|
|
require.NoError(t, Execute(context.Background(), deps, args))
|
|
require.Empty(t, out.String())
|
|
data, err := os.ReadFile(path)
|
|
require.NoError(t, err)
|
|
require.Contains(t, string(data), "tea-pr-checkout")
|
|
require.Contains(t, string(data), "detach")
|
|
require.Equal(t, clierr.Usage, clierr.ExitCode(Execute(context.Background(), deps, args)))
|
|
after, err := os.ReadFile(path)
|
|
require.NoError(t, err)
|
|
require.Equal(t, data, after)
|
|
}
|
|
|
|
func TestManRejectsUnknownCommandsAndMachineOutput(t *testing.T) {
|
|
for _, args := range [][]string{{"man", "unknown"}, {"man", "pr", "unknown"}, {"man", "--json"}, {"man", "--jq", "."}} {
|
|
deps, out, _ := testDeps(t)
|
|
require.Equal(t, clierr.Usage, clierr.ExitCode(Execute(context.Background(), deps, args)))
|
|
require.Empty(t, out.String())
|
|
}
|
|
}
|
|
|
|
func TestManIncludesFullCommandTree(t *testing.T) {
|
|
deps, out, _ := testDeps(t)
|
|
require.NoError(t, Execute(context.Background(), deps, []string{"man"}))
|
|
manual := out.String()
|
|
for _, command := range []string{"tea-pr-checkout", "tea-issue-comment-create", "tea-auth-login", "tea-run-artifact-list"} {
|
|
require.Contains(t, manual, command)
|
|
}
|
|
require.Contains(t, manual, `.TH "TEA-PR-CHECKOUT" "1" "Jan 2026"`)
|
|
require.NotContains(t, manual, "tea-auth-git-credential")
|
|
first := manual
|
|
out.Reset()
|
|
require.NoError(t, Execute(context.Background(), deps, []string{"man"}))
|
|
require.Equal(t, first, out.String())
|
|
out.Reset()
|
|
deps.Getenv = envFunc(map[string]string{"SOURCE_DATE_EPOCH": "1780000000"})
|
|
require.NoError(t, Execute(context.Background(), deps, []string{"man", "pr", "checkout"}))
|
|
require.Contains(t, out.String(), `.TH "TEA-PR-CHECKOUT" "1" "May 2026"`)
|
|
}
|
|
|
|
func TestCanceledManDoesNotPublishOutputFile(t *testing.T) {
|
|
deps, out, _ := testDeps(t)
|
|
path := filepath.Join(t.TempDir(), "manual.1")
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
cancel()
|
|
require.ErrorIs(t, Execute(ctx, deps, []string{"man", "--output-file", path}), context.Canceled)
|
|
_, err := os.Stat(path)
|
|
require.True(t, os.IsNotExist(err))
|
|
require.Empty(t, out.String())
|
|
}
|