Files
archie/internal/forge/github_test.go
T
sam 4ee8579ddc refactor: phase 2 of lint remediation — mechanical fixes (qa4)
130 -> 96. forcetypeassert, predeclared and usetesting are now at zero.

Fanned out across four isolated worktrees partitioned by package so no
two workers could touch the same file: internal/tools (20 assertions),
internal/webui, internal/memory + internal/ratelimit, internal/secret.
Four stragglers outside those scopes fixed inline (internal/pairing,
internal/forge, internal/channels/telegram, internal/tools/mcp).

Unchecked type assertions became comma-ok with a t.Fatalf naming the
actual type. One site in a goroutine uses t.Errorf + return instead,
since t.Fatalf from a non-test goroutine is undefined behaviour.

predeclared renames chose names from meaning rather than adding a
suffix: max -> maxQueryLen, maxMatchLen, maxRequests, alphabetLen, and
nextBackoff's max -> ceiling. `real` -> `base` in the webui tests.

os.Setenv became t.Setenv, which restores on cleanup, so the paired
deferred Unsetenv calls went with it.

Note for future fan-outs: the agent worktrees branched from origin/main
(a7388a0), not from this branch, so every diff arrived based on a tree
without the phase 1 autofix. They were applied with `git apply --3way`
and the phase 1 changes to internal/memory/manager.go were verified to
survive — in particular the repaired `ctx, cancel =` assignment. A plain
`git apply` would have silently reverted it.
2026-07-28 01:37:20 +10:00

48 lines
1.1 KiB
Go

package forge
import (
"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.DiscardHandler))
if err != nil {
t.Fatal(err)
}
client, ok := f.(*GitHubClient)
if !ok {
t.Fatalf("f is %T, want *GitHubClient", f)
}
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)
}
})
}
}