Files
zeekay f5ff92c37f fix: repair Go identifier errors and protobuf from rebrand
The AgentField-to-HanzoAgents rebrand introduced invalid Go
identifiers (hanzo-agentsXxx with hyphens), corrupted protobuf
raw descriptors, and missing TypeScript type exports. This commit:

- Renames all `hanzo-agentsXxx` Go vars to `hanzoAgentsXxx`
- Regenerates protobuf .pb.go with correct go_package path
- Copies agentfield.ts types to hanzo-agents.ts for UI build
- Adds amd64 cross-compiler support to Dockerfile
2026-02-09 23:16:43 -08:00

86 lines
2.6 KiB
Go

package application
import (
"context"
"path/filepath"
"strings"
"testing"
"github.com/hanzoai/agents/control-plane/internal/config"
storagecfg "github.com/hanzoai/agents/control-plane/internal/storage"
)
func TestCreateServiceContainerWithoutDID(t *testing.T) {
t.Parallel()
hanzoAgentsHome := t.TempDir()
cfg := &config.Config{}
container := CreateServiceContainer(cfg, hanzoAgentsHome)
if container.PackageService == nil || container.AgentService == nil || container.DevService == nil {
t.Fatalf("expected core services to be initialised")
}
if container.DIDService != nil || container.VCService != nil {
t.Fatalf("expected DID services to be nil when feature disabled")
}
}
func TestCreateServiceContainerDIDWithoutStorageFallback(t *testing.T) {
t.Parallel()
hanzoAgentsHome := t.TempDir()
cfg := &config.Config{}
cfg.Features.DID.Enabled = true
cfg.Features.DID.Keystore.Path = filepath.Join(hanzoAgentsHome, "keys")
cfg.Storage.Mode = "invalid"
container := CreateServiceContainer(cfg, hanzoAgentsHome)
if container.DIDService != nil || container.VCService != nil {
t.Fatalf("expected DID services to remain nil when storage initialisation fails")
}
}
func TestCreateServiceContainerWithLocalDID(t *testing.T) {
t.Parallel()
hanzoAgentsHome := t.TempDir()
cfg := &config.Config{}
cfg.Storage.Mode = "local"
cfg.Storage.Local = storagecfg.LocalStorageConfig{
DatabasePath: filepath.Join(hanzoAgentsHome, "hanzo-agents.db"),
KVStorePath: filepath.Join(hanzoAgentsHome, "hanzo-agents.bolt"),
}
cfg.Features.DID.Enabled = true
cfg.Features.DID.Keystore.Path = filepath.Join(hanzoAgentsHome, "keys")
ctx := context.Background()
probe := storagecfg.NewLocalStorage(storagecfg.LocalStorageConfig{})
storageConfig := storagecfg.StorageConfig{
Mode: cfg.Storage.Mode,
Local: cfg.Storage.Local,
}
if err := probe.Initialize(ctx, storageConfig); err != nil {
if strings.Contains(strings.ToLower(err.Error()), "fts5") {
t.Skip("sqlite3 compiled without FTS5; skipping DID container test")
}
t.Fatalf("failed to initialise local storage: %v", err)
}
if err := probe.Close(ctx); err != nil {
t.Fatalf("failed to close probe storage: %v", err)
}
container := CreateServiceContainer(cfg, hanzoAgentsHome)
if container.DIDService == nil {
t.Fatalf("expected DID service to be initialised when configuration is valid")
}
if container.VCService == nil {
t.Fatalf("expected VC service to be initialised when configuration is valid")
}
if container.StorageProvider == nil {
t.Fatalf("expected storage provider to be initialised for DID services")
}
}