Files
archie/internal/forge/github_test.go
T

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("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)
}
})
}
}