63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal"
|
|
"github.com/sipeed/picoclaw/pkg/config"
|
|
)
|
|
|
|
func TestNewPicoclawCommand(t *testing.T) {
|
|
cmd := NewPicoclawCommand()
|
|
|
|
require.NotNil(t, cmd)
|
|
|
|
short := fmt.Sprintf("%s PicoClaw — personal AI assistant", internal.Logo)
|
|
longHas := strings.Contains(cmd.Long, config.FormatVersion())
|
|
|
|
assert.Equal(t, "picoclaw", cmd.Use)
|
|
assert.Equal(t, short, cmd.Short)
|
|
assert.True(t, longHas)
|
|
|
|
assert.True(t, cmd.HasSubCommands())
|
|
assert.True(t, cmd.HasAvailableSubCommands())
|
|
|
|
assert.True(t, cmd.PersistentFlags().Lookup("no-color") != nil)
|
|
|
|
assert.Nil(t, cmd.Run)
|
|
assert.Nil(t, cmd.RunE)
|
|
|
|
assert.NotNil(t, cmd.PersistentPreRun)
|
|
assert.Nil(t, cmd.PersistentPostRun)
|
|
|
|
allowedCommands := []string{
|
|
"agent",
|
|
"auth",
|
|
"cron",
|
|
"gateway",
|
|
"mcp",
|
|
"migrate",
|
|
"model",
|
|
"onboard",
|
|
"skills",
|
|
"status",
|
|
"update",
|
|
"version",
|
|
}
|
|
|
|
subcommands := cmd.Commands()
|
|
assert.Len(t, subcommands, len(allowedCommands))
|
|
|
|
for _, subcmd := range subcommands {
|
|
found := slices.Contains(allowedCommands, subcmd.Name())
|
|
assert.True(t, found, "unexpected subcommand %q", subcmd.Name())
|
|
|
|
assert.False(t, subcmd.Hidden)
|
|
}
|
|
}
|