test: add some unit tests
This commit is contained in:
parent
1d94431825
commit
6ab7ccb7a1
3 changed files with 263 additions and 0 deletions
28
internal/api/client_test.go
Normal file
28
internal/api/client_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue