Files
gitea-tea/cmd/pulls/stack/list_test.go
Lunny Xiao ba167a7352 feat(pulls): add tea pr stack list|show|push|restack|merge
Adds a CLI client for the Gitea EE pull request stack API
(GET/POST /repos/{owner}/{repo}/stacks[/{id}[/entries|/restack|/merge]]):

- modules/stack holds the Stack/Entry/MergeResult types shared between
  the API client and its output formatting, avoiding an import cycle
  between modules/task and modules/print.
- modules/task/pull_stack.go implements the HTTP calls on top of
  modules/api.Client, which gains a context-aware DoContext method.
- modules/print/pull_stack.go formats stack listings (table/json/...)
  and a single stack's ordered entries.
- cmd/pulls/stack adds the list, show, push, restack and merge
  subcommands, wired in as 'tea pr stack' via cmd/pulls.go, following
  the repo/login flag routing used by the rest of the pulls commands.

Assisted-by: Codet:GPT-5-Codex
2026-09-24 23:24:26 -07:00

44 lines
889 B
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package stack
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/urfave/cli/v3"
"gitea.dev/tea/modules/config"
)
func TestRunStackListRequiresRepoContext(t *testing.T) {
oldWd, err := os.Getwd()
require.NoError(t, err)
require.NoError(t, os.Chdir(t.TempDir()))
t.Cleanup(func() {
require.NoError(t, os.Chdir(oldWd))
})
config.SetConfigForTesting(config.LocalConfig{
Logins: []config.Login{{
Name: "test",
URL: "https://gitea.example.com",
Token: "token",
User: "tester",
Default: true,
}},
})
cmd := &cli.Command{
Name: CmdStackList.Name,
Flags: CmdStackList.Flags,
}
require.NoError(t, cmd.Set("login", "test"))
err = RunStackList(t.Context(), cmd)
require.ErrorContains(t, err, "remote repository required")
}