New commands: - fgj api: raw REST API passthrough with field inference and path interpolation - fgj pr diff: view PR diffs with color, --name-only, --stat - fgj pr comment: add comments to pull requests - fgj pr review: approve, request changes, or comment on PRs Agentic enhancements: - --json-errors flag for structured JSON error output on stderr - APIError type wrapping HTTP status codes for machine consumption - Error codes: auth_required, not_found, api_error, invalid_input, etc. Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"forgejo.zerova.net/sid/fgj-sid/internal/config"
|
|
)
|
|
|
|
func TestClient_Hostname(t *testing.T) {
|
|
client := &Client{
|
|
hostname: "codeberg.org",
|
|
}
|
|
|
|
if client.Hostname() != "codeberg.org" {
|
|
t.Errorf("Expected hostname 'codeberg.org', got '%s'", client.Hostname())
|
|
}
|
|
}
|
|
|
|
func TestNewClientFromConfig_MissingHost(t *testing.T) {
|
|
cfg := &config.Config{
|
|
Hosts: map[string]config.HostConfig{},
|
|
}
|
|
|
|
_, err := NewClientFromConfig(cfg, "nonexistent.org", "")
|
|
if err == nil {
|
|
t.Error("Expected error for nonexistent host")
|
|
}
|
|
}
|
|
|
|
func TestNewClient_EmptyHostname(t *testing.T) {
|
|
t.Skip("Skipping: NewClient makes actual network calls")
|
|
// Empty hostname should default to codeberg.org
|
|
// This test would require mocking the gitea client
|
|
}
|
|
|
|
func TestNewClient_WithHostname(t *testing.T) {
|
|
t.Skip("Skipping: NewClient makes actual network calls")
|
|
// This test would require mocking the gitea client
|
|
}
|
|
|
|
func TestNewClient_EmptyToken(t *testing.T) {
|
|
t.Skip("Skipping: NewClient makes actual network calls")
|
|
// Empty token should work (for public repos)
|
|
// This test would require mocking the gitea client
|
|
}
|
|
|
|
func TestNewClientFromConfig_ValidHost(t *testing.T) {
|
|
t.Skip("Skipping: NewClient makes actual network calls")
|
|
// This test would require mocking the gitea client
|
|
}
|
|
|
|
func TestNewClientFromConfig_EmptyHostname(t *testing.T) {
|
|
t.Skip("Skipping: NewClient makes actual network calls")
|
|
// Empty hostname should trigger GetHost logic (falls back to codeberg.org)
|
|
// This test would require mocking the gitea client
|
|
}
|