Files
hanzoai_agent/control-plane/internal/server/package_sync_test.go
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

68 lines
1.7 KiB
Go

package server
import (
"os"
"path/filepath"
"testing"
"time"
"github.com/hanzoai/agents/control-plane/pkg/types"
"github.com/stretchr/testify/require"
)
func TestSyncPackagesFromRegistryStoresMissingPackages(t *testing.T) {
t.Parallel()
hanzoAgentsHome := t.TempDir()
pkgDir := filepath.Join(hanzoAgentsHome, "example-agent")
require.NoError(t, os.MkdirAll(pkgDir, 0o755))
installed := `installed:
example-agent:
name: Example Agent
version: 1.0.0
description: demo agent
path: ` + pkgDir + `
source: local
status: installed
`
require.NoError(t, os.WriteFile(filepath.Join(hanzoAgentsHome, "installed.yaml"), []byte(installed), 0o644))
packageYAML := `name: Example Agent
version: 1.0.0
schema:
type: object
`
require.NoError(t, os.WriteFile(filepath.Join(pkgDir, "hanzo-agents-package.yaml"), []byte(packageYAML), 0o644))
storage := newStubPackageStorage()
require.NoError(t, SyncPackagesFromRegistry(hanzoAgentsHome, storage))
pkg, ok := storage.packages["example-agent"]
require.True(t, ok)
require.Equal(t, "Example Agent", pkg.Name)
require.NotEmpty(t, pkg.ConfigurationSchema)
}
func TestSyncPackagesSkipsExistingEntries(t *testing.T) {
t.Parallel()
hanzoAgentsHome := t.TempDir()
installed := `installed:
existing-agent:
name: Existing
version: 0.1.0
description: already present
path: ` + hanzoAgentsHome + `
`
require.NoError(t, os.WriteFile(filepath.Join(hanzoAgentsHome, "installed.yaml"), []byte(installed), 0o644))
storage := newStubPackageStorage()
storage.packages["existing-agent"] = &types.AgentPackage{ID: "existing-agent", Name: "Existing", InstalledAt: time.Now()}
require.NoError(t, SyncPackagesFromRegistry(hanzoAgentsHome, storage))
require.Len(t, storage.packages, 1)
}