test: update the integration tests to the 1.0 command and output behavior

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 17:14:46 +02:00
1 parent 061652810a
commit 843c3c2977
3 files changed
+14 -10

No files matched your search

@@ -86,7 +86,7 @@ func TestGiteaGitCredentialHelperClonesPrivateRepository(t *testing.T) {
var checkout git.CheckoutResult
require.NoError(t, json.Unmarshal(out.Bytes(), &checkout))
require.Equal(t, pull.HeadSHA, checkout.Commit)
require.Equal(t, "pr/"+fmt.Sprint(pull.Number), checkout.Branch)
require.Equal(t, "feature", checkout.Branch)
branchesBefore, err := runner.Output(context.Background(), teaClone, false, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads/")
require.NoError(t, err)
out.Reset()
@@ -102,7 +102,7 @@ func TestGiteaGitCredentialHelperClonesPrivateRepository(t *testing.T) {
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", fmt.Sprint(pull.Number), "-R", repo.FullName, "--cwd", teaClone, "--no-input", "--json"}))
require.NoError(t, json.Unmarshal(out.Bytes(), &checkout))
require.False(t, checkout.Detached)
require.Equal(t, "pr/"+fmt.Sprint(pull.Number), checkout.Branch)
require.Equal(t, "feature", checkout.Branch)
branchesAfter, err = runner.Output(context.Background(), teaClone, false, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads/")
require.NoError(t, err)
require.Equal(t, branchesBefore, branchesAfter)
@@ -131,12 +131,13 @@ func TestGiteaGitCredentialHelperClonesPrivateRepository(t *testing.T) {
var synced git.SyncResult
require.NoError(t, json.Unmarshal(out.Bytes(), &synced))
require.Equal(t, repo.DefaultBranch, synced.Branch)
localHead, err = runner.Output(context.Background(), teaClone, false, "rev-parse", "HEAD")
// Sync updates the branch without switching to it, so read the branch rather than HEAD.
localHead, err = runner.Output(context.Background(), teaClone, false, "rev-parse", "refs/heads/"+synced.Branch)
require.NoError(t, err)
require.Equal(t, synced.Commit, localHead)
contents, err := os.ReadFile(filepath.Join(teaClone, "sync.txt"))
contents, err := runner.Output(context.Background(), teaClone, false, "show", synced.Branch+":sync.txt")
require.NoError(t, err)
require.Equal(t, "sync\n", string(contents))
require.Equal(t, "sync", strings.TrimSpace(contents))
if endpoint := os.Getenv("GITEA_TEA_TEST_SSH_ENDPOINT"); endpoint != "" {
verifySSHCloneAndCheckout(t, deps, repo, pull, user, environment, endpoint)
}
+7 -4
View File
@@ -12,6 +12,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strconv"
"strings"
"testing"
@@ -101,7 +102,7 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
require.Contains(t, foundRepos, generated)
execute("api", "user/starred/"+generated.FullName, "--method", "PUT")
require.NoError(t, json.Unmarshal(execute("repo", "list", "--starred", "--json"), &foundRepos))
require.Contains(t, foundRepos, generated)
require.True(t, slices.ContainsFunc(foundRepos, func(r services.Repository) bool { return r.ID == generated.ID }), "starred list misses the repository")
execute("api", "user/starred/"+generated.FullName, "--method", "DELETE")
require.NoError(t, json.Unmarshal(execute("repo", "list", "--watched", "--limit", "1", "--page", "2", "--json"), &foundRepos))
require.Len(t, foundRepos, 1)
@@ -333,7 +334,9 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
out.Reset()
diagnostics.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"release", "asset", "delete", "v1", bulkAssets[0].Name, bulkAssets[1].Name, "--by-name", "-R", repo.FullName, "--yes"}))
require.Contains(t, diagnostics.String(), "Deleted asset")
require.Empty(t, diagnostics.String(), "confirmation lines are only written on a terminal")
require.NoError(t, json.Unmarshal(scoped("release", "asset", "list", "v1"), &assets))
require.Empty(t, assets)
scoped("release", "create", "v2", "--asset", assetFile)
require.NoError(t, json.Unmarshal(scoped("release", "asset", "list", "v2"), &assets))
require.Len(t, assets, 1)
@@ -425,11 +428,11 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
t.Errorf("organization repository cleanup: %v", err)
}
})
execute("team", "repo", "add", teamID, "-R", orgRepo.FullName)
execute("team", "repo", "add", teamID, orgRepo.FullName)
var teamRepos []services.Repository
require.NoError(t, json.Unmarshal(execute("team", "repo", "list", teamID, "--json"), &teamRepos))
require.Len(t, teamRepos, 1)
execute("team", "repo", "remove", teamID, "-R", orgRepo.FullName, "--yes")
execute("team", "repo", "remove", teamID, orgRepo.FullName, "--yes")
require.Equal(t, "[]\n", string(execute("team", "repo", "list", teamID, "--json")))
execute("team", "delete", teamID, "--yes")
execute("variable", "set", "ORG_MODE", "--org", orgName, "--value", "org value")
+1 -1
View File
@@ -47,7 +47,7 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
execute("label", "export", "-R", repo.FullName, "--output-file", exportPath)
exported, err := os.ReadFile(exportPath)
require.NoError(t, err)
require.Contains(t, string(exported), "00ff00 review ;")
require.Contains(t, string(exported), "#00ff00 review\n")
jsonExportPath := exportPath + ".json"
execute("label", "export", "-R", repo.FullName, "--output-file", jsonExportPath, "--json")
jsonExport, err := os.ReadFile(jsonExportPath)