This commit is contained in:
Lunny Xiao
2026-05-06 17:18:27 -07:00
parent 6af01bb13d
commit 4ff3775934

View File

@@ -7,10 +7,25 @@ import (
"context" "context"
"testing" "testing"
"code.gitea.io/tea/modules/config"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestReply(t *testing.T) { func TestReply(t *testing.T) {
config.SetConfigForTesting(config.LocalConfig{
Logins: []config.Login{{
Name: "testLogin",
URL: "https://gitea.example.com",
Token: "test-token",
User: "testUser",
Default: true,
}},
})
t.Cleanup(func() {
config.SetConfigForTesting(config.LocalConfig{})
})
tests := []struct { tests := []struct {
name string name string
args []string args []string
@@ -41,7 +56,7 @@ func TestReply(t *testing.T) {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := CmdPullsReply cmd := CmdPullsReply
args := append([]string{"reply"}, tt.args...) args := append([]string{"reply"}, tt.args...)
args = append(args, "--repo", "user/repo") args = append(args, "--login", "testLogin", "--repo", "user/repo")
err := cmd.Run(context.Background(), args) err := cmd.Run(context.Background(), args)
if tt.wantErr { if tt.wantErr {
assert.Error(t, err) assert.Error(t, err)