Files
hanzoai_agent/control-plane/internal/cli/root_test.go
zeekay 2899aeaa9f feat: merge agents control plane + SDKs into unified agent repo
Consolidate all Hanzo agent infrastructure into one repo:
- control-plane/: Go control plane server (was agents-new)
- sdk/: Go, Python, TypeScript SDKs
- deployments/: Docker, Kubernetes, Helm configs
- Dockerfile.sdk: Python SDK image (ghcr.io/hanzoai/agent:latest)
- CI builds both SDK + control-plane images

No more agentfield — everything is hanzoai/agent.
2026-02-13 12:24:31 -08:00

94 lines
2.0 KiB
Go

package cli
import (
"io"
"os"
"path/filepath"
"testing"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
)
func resetCLIStateForTest() {
cfgFile = ""
verbose = false
openBrowserFlag = true
uiDevFlag = false
backendOnlyFlag = false
portFlag = 0
noVCExecution = false
}
func TestRootCommandDisplaysHelp(t *testing.T) {
t.Setenv("HOME", t.TempDir())
resetCLIStateForTest()
cmd := NewRootCommand(func(cmd *cobra.Command, args []string) {}, VersionInfo{
Version: "test",
Commit: "test",
Date: "test",
})
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
cmd.SetArgs([]string{"--help"})
require.NoError(t, cmd.Execute())
}
func TestRootCommandServerFlags(t *testing.T) {
t.Setenv("HOME", t.TempDir())
resetCLIStateForTest()
invoked := false
cmd := NewRootCommand(func(cmd *cobra.Command, args []string) {
invoked = true
require.False(t, GetOpenBrowserFlag())
require.True(t, GetBackendOnlyFlag())
require.True(t, GetUIDevFlag())
require.Equal(t, 9090, GetPortFlag())
require.True(t, noVCExecution)
}, VersionInfo{
Version: "test",
Commit: "test",
Date: "test",
})
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
cmd.SetArgs([]string{
"server",
"--open=false",
"--backend-only",
"--ui-dev",
"--port=9090",
"--no-vc-execution",
})
require.NoError(t, cmd.Execute())
require.True(t, invoked)
}
func TestRootCommandHonorsConfigFlag(t *testing.T) {
t.Setenv("HOME", t.TempDir())
resetCLIStateForTest()
configDir := t.TempDir()
configPath := filepath.Join(configDir, "hanzo-agents.yaml")
require.NoError(t, os.WriteFile(configPath, []byte("hanzo-agents:\n port: 7000\n"), 0o644))
var received string
cmd := NewRootCommand(func(cmd *cobra.Command, args []string) {
received = GetConfigFilePath()
}, VersionInfo{
Version: "test",
Commit: "test",
Date: "test",
})
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
cmd.SetArgs([]string{"--config", configPath, "server", "--open=false"})
require.NoError(t, cmd.Execute())
require.Equal(t, configPath, received)
}