2025-12-08 10:14:47 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-04-26 08:16:52 -06:00
|
|
|
"forgejo.zerova.net/public/fj/internal/config"
|
2025-12-08 10:14:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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{},
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-23 12:39:51 -06:00
|
|
|
_, err := NewClientFromConfig(cfg, "nonexistent.org", "", "")
|
2025-12-08 10:14:47 +01:00
|
|
|
if err == nil {
|
|
|
|
|
t.Error("Expected error for nonexistent host")
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-15 15:07:42 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|