Phase 1 test coverage for the three 0% packages plus agentci/ improvement: - git/ (0% -> 79.5%): RepoStatus methods, status parsing with real temp repos, multi-repo parallel status, Push/Pull error paths, ahead/behind with bare remote, context cancellation, GitError, IsNonFastForward, service DirtyRepos/AheadRepos filtering - forge/ (0% -> 91.2%): All SDK wrapper functions tested via httptest mock server — client creation, repos, issues, PRs, labels, webhooks, orgs, meta, config resolution, SetPRDraft raw HTTP endpoint - gitea/ (0% -> 89.2%): All SDK wrapper functions tested via httptest mock server — client creation, repos, issues, PRs, meta, config resolution - agentci/ (56% -> 94.5%): Clotho DeterminePlan all code paths, security helpers (SanitizePath, EscapeShellArg, SecureSSHCommand, MaskToken) Key findings documented in FINDINGS.md: - Forgejo SDK validates token via HTTP on NewClient() - SDK route patterns differ from public API docs (/org/ vs /orgs/) - Gitea SDK requires auth token for GitHub mirror creation - Config resolution priority verified: config file < env vars < flags Co-Authored-By: Charon <developers@lethean.io>
38 lines
798 B
Go
38 lines
798 B
Go
package gitea
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNew_Good(t *testing.T) {
|
|
srv := newMockGiteaServer(t)
|
|
defer srv.Close()
|
|
|
|
client, err := New(srv.URL, "test-token-123")
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, client)
|
|
assert.NotNil(t, client.API())
|
|
assert.Equal(t, srv.URL, client.URL())
|
|
}
|
|
|
|
func TestNew_Bad_InvalidURL(t *testing.T) {
|
|
_, err := New("://invalid-url", "token")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestClient_API_Good(t *testing.T) {
|
|
client, srv := newTestClient(t)
|
|
defer srv.Close()
|
|
|
|
assert.NotNil(t, client.API(), "API() should return the underlying SDK client")
|
|
}
|
|
|
|
func TestClient_URL_Good(t *testing.T) {
|
|
client, srv := newTestClient(t)
|
|
defer srv.Close()
|
|
|
|
assert.Equal(t, srv.URL, client.URL())
|
|
}
|