mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-05 19:32:53 +02:00
Add test fixture
This commit is contained in:
@ -6,15 +6,22 @@ package repos
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/cmd/login"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func TestCreateRepoObjectFormat(t *testing.T) {
|
||||
giteaURL := os.Getenv("GITEA_TEA_TEST_URL")
|
||||
if giteaURL == "" {
|
||||
t.Skip("GITEA_TEA_TEST_URL is not set, skipping test")
|
||||
}
|
||||
|
||||
timestamp := time.Now().Unix()
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -49,13 +56,26 @@ func TestCreateRepoObjectFormat(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
loginAddCmd := &cli.Command{
|
||||
Name: "add",
|
||||
Commands: []*cli.Command{
|
||||
&login.CmdLoginAdd,
|
||||
},
|
||||
}
|
||||
giteaUserName := os.Getenv("GITEA_TEA_TEST_USERNAME")
|
||||
giteaUserPasword := os.Getenv("GITEA_TEA_TEST_PASSWORD")
|
||||
args := []string{"add", "--name", "test-login", "--url", giteaURL, "--user", giteaUserName, "--password", giteaUserPasword}
|
||||
err := loginAddCmd.Run(context.Background(), args)
|
||||
assert.NoError(t, err)
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
reposCmd := &cli.Command{
|
||||
Name: "repos",
|
||||
Aliases: []string{"repo"},
|
||||
Name: "repos",
|
||||
|
||||
Commands: []*cli.Command{&CmdRepoCreate},
|
||||
}
|
||||
tt.args = append(tt.args, "--login", "test-login")
|
||||
args := append([]string{"repos", "create"}, tt.args...)
|
||||
|
||||
err := reposCmd.Run(context.Background(), args)
|
||||
|
Reference in New Issue
Block a user