test: add some unit tests

This commit is contained in:
Romain Bertrand 2025-12-08 10:14:47 +01:00
parent 1d94431825
commit 6ab7ccb7a1
3 changed files with 263 additions and 0 deletions

View file

@ -0,0 +1,28 @@
package api
import (
"testing"
"codeberg.org/romaintb/fgj/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")
}
}