xonecas.io
60255
Zn

Zoea-Nova / commit 96083ba

test: add registry bug reproduction test

xonecas2026-02-07 96083ba102101eb21d78ebc0d5303c97fb3322eb parent 410f8b9

1 file changed

internal/provider/registry_bug_test.go+66−0
@@ -0,0 +1,66 @@
1+package provider
2+
3+import (
4+ "strings"
5+ "testing"
6+
7+ "github.com/xonecas/zoea-nova/internal/config"
8+)
9+
10+// TestZenNanoRegistration reproduces the production bug where zen-nano provider
11+// is defined in config but fails with "provider not found".
12+func TestZenNanoRegistration(t *testing.T) {
13+ // Simulate exact production config
14+ cfg := &config.Config{
15+ Swarm: config.SwarmConfig{
16+ MaxMyses: 16,
17+ DefaultProvider: "zen-nano",
18+ DefaultModel: "gpt-5-nano",
19+ },
20+ Providers: map[string]config.ProviderConfig{
21+ "zen-nano": {
22+ Endpoint: "https://opencode.ai/zen/v1",
23+ Model: "gpt-5-nano",
24+ Temperature: 0.7,
25+ RateLimit: 1.0,
26+ RateBurst: 2,
27+ },
28+ },
29+ }
30+
31+ // Simulate initProviders logic from main.go
32+ registry := NewRegistry()
33+ creds := &config.Credentials{}
34+ creds.SetAPIKey("opencode", "test-api-key")
35+
36+ // This is EXACTLY what initProviders does
37+ for name, provCfg := range cfg.Providers {
38+ if strings.Contains(provCfg.Endpoint, "localhost:11434") || strings.Contains(provCfg.Endpoint, "/ollama") {
39+ factory := NewOllamaFactory(provCfg.Endpoint, provCfg.RateLimit, provCfg.RateBurst)
40+ registry.RegisterFactory(name, factory)
41+ t.Logf("Registered Ollama provider: %s", name)
42+ } else if strings.Contains(provCfg.Endpoint, "opencode.ai") {
43+ apiKey := creds.GetAPIKey("opencode")
44+ if apiKey != "" {
45+ factory := NewOpenCodeFactory(provCfg.Endpoint, apiKey, provCfg.RateLimit, provCfg.RateBurst)
46+ registry.RegisterFactory(name, factory)
47+ t.Logf("Registered OpenCode provider: %s", name)
48+ }
49+ }
50+ }
51+
52+ // List what's in registry
53+ registeredProviders := registry.List()
54+ t.Logf("Registry has %d providers", len(registeredProviders))
55+ for _, name := range registeredProviders {
56+ t.Logf(" Registry contains: %s", name)
57+ }
58+
59+ // This is what Commander.CreateMysis does
60+ _, err := registry.Create("zen-nano", "gpt-5-nano", 0.7)
61+ if err != nil {
62+ t.Fatalf("REPRODUCTION: zen-nano provider creation failed: %v\nThis reproduces the production bug.", err)
63+ }
64+
65+ t.Log("SUCCESS: zen-nano provider created")
66+}