ide/main_test.go
Snider e1024744a4
Some checks failed
Security Scan / security (pull_request) Successful in 11s
Test / test (pull_request) Failing after 1m56s
fix(ide): replace fmt.Errorf with coreerr.E(), add unit tests
Replace all fmt.Errorf calls in runtime.go with structured errors via
coreerr.E() from go-log, ensuring every error carries operation context
for structured logging and tracing.

Add unit tests for runtime utilities (findFreePort, waitForHealth,
defaultProvidersDir), RuntimeManager (List, StopAll, StartAll),
ProvidersAPI (Name, BasePath, list endpoint), guiEnabled, and
staticAssetGroup. Coverage: 27.1%.

No os.ReadFile/os.WriteFile violations found. CLAUDE.md reviewed —
no outdated commands.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 09:00:18 +00:00

33 lines
801 B
Go

package main
import (
"testing"
"forge.lthn.ai/core/config"
"github.com/stretchr/testify/assert"
)
func TestGuiEnabled_Good_NilConfig(t *testing.T) {
// nil config should fall through to display detection.
result := guiEnabled(nil)
// On macOS/Windows this returns true; on Linux it depends on DISPLAY.
// Just verify it doesn't panic.
_ = result
}
func TestGuiEnabled_Good_WithConfig(t *testing.T) {
cfg, _ := config.New()
// Fresh config has no gui.enabled key — should fall through to OS detection.
result := guiEnabled(cfg)
_ = result
}
func TestStaticAssetGroup_Good(t *testing.T) {
s := &staticAssetGroup{
name: "test-assets",
basePath: "/assets/test",
dir: "/tmp",
}
assert.Equal(t, "test-assets", s.Name())
assert.Equal(t, "/assets/test", s.BasePath())
}