Files
zeekay 63bde13037 fix: replace invalid hyphenated Go identifiers with camelCase
The bulk rename from agentfield to hanzo-agents introduced hyphens into
Go variable names (e.g. hanzo-agentsHome), which are not valid Go
identifiers. Fixed 361 occurrences across 36 files to use camelCase
(e.g. hanzoAgentsHome). String literals like ".hanzo-agents" are
preserved as-is.
2026-02-13 12:43:38 -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")
}
}