test: improve coverage for API, AI, Alerts, and Frontend Utils

- Add comprehensive tests for internal/api/config_handlers.go (Phases 1-3)
- Improve test coverage for AI tools, chat service, and session management
- Enhance alert and notification tests (ResolvedAlert, Webhook)
- Add frontend unit tests for utils (searchHistory, tagColors, temperature, url)
- Add proximity client API tests
This commit is contained in:
rcourtman 2026-01-20 15:52:39 +00:00
parent 2c561cbea7
commit 96b7370f7b
40 changed files with 5061 additions and 1466 deletions

View file

@ -0,0 +1,32 @@
package api
import (
"testing"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
)
func TestGenerateSetupCode(t *testing.T) {
tempDir := t.TempDir()
cfg := &config.Config{
DataPath: tempDir,
ConfigPath: tempDir,
}
handler := newTestConfigHandlers(t, cfg)
// Test 1: Basic generation
code := handler.generateSetupCode()
if len(code) != 32 { // 16 bytes hex encoded = 32 chars
t.Errorf("expected code length 32, got %d", len(code))
}
// Verify uniqueness
code2 := handler.generateSetupCode()
if code == code2 {
t.Error("generated codes should be unique (random)")
}
// Storage is handled by HandleSetupScriptURL, not generateSetupCode.
// So we don't verify storage here.
}