Implements the Forge interface for Gitea instances (tested against git.catlow.cloud, Gitea v1.26.4). The forge.New factory now dispatches on forge type, and config validation accepts 'gitea'. Changes: - internal/forge/gitea.go — GiteaClient implementing all 11 Forge methods: issue polling (assigned + label), comments, PR creation, PR state reconciliation, issue closure, reactions, state labels, push verification. Handles edge cases: not-found PRs return 'closed', GetUserByName errors from the Gitea SDK are mapped to user-friendly messages. - internal/forge/forge.go — New() factory dispatching on forge type (github/gitea). GitHub constructor renamed to NewGitHub. - internal/forge/github_test.go — updated to use New() signature - internal/config/config.go — forge.type accepts 'gitea', BotEmail defaults change per forge type (gitea uses @gitea.local) - cmd/archied/main.go — passes cfg.Forge.Type to forge.New() Dependencies: added code.gitea.io/sdk/gitea v0.25.1 End-to-end verified against live Gitea instance: daemon starts clean, registry built (5 workflows), web UI listening, no errors or warnings.
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package forge
|
|
|
|
import (
|
|
"io"
|
|
"log/slog"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewConfiguresHost(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
host string
|
|
wantBase string
|
|
wantUpload string
|
|
}{
|
|
{
|
|
name: "github.com",
|
|
host: "https://github.com",
|
|
wantBase: "https://api.github.com/",
|
|
wantUpload: "https://uploads.github.com/",
|
|
},
|
|
{
|
|
name: "enterprise",
|
|
host: "https://git.example.com",
|
|
wantBase: "https://git.example.com/api/v3/",
|
|
wantUpload: "https://git.example.com/api/uploads/",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
f, err := New("github", "token", tt.host, slog.New(slog.NewTextHandler(io.Discard, nil)))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
client := f.(*GitHubClient)
|
|
if got := client.gh.BaseURL.String(); got != tt.wantBase {
|
|
t.Errorf("BaseURL = %q, want %q", got, tt.wantBase)
|
|
}
|
|
if got := client.gh.UploadURL.String(); got != tt.wantUpload {
|
|
t.Errorf("UploadURL = %q, want %q", got, tt.wantUpload)
|
|
}
|
|
})
|
|
}
|
|
}
|