mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
dfa36f39cb
* add model command to set default model * fix for ci * fix test for model * fix active agent not recognized * implement test for model command * fix local-model can not set as default issue * fix review comment * fix for comment
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"slices"
|
|
"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 v%s\n\n", internal.Logo, config.GetVersion())
|
|
|
|
assert.Equal(t, "picoclaw", cmd.Use)
|
|
assert.Equal(t, short, cmd.Short)
|
|
|
|
assert.True(t, cmd.HasSubCommands())
|
|
assert.True(t, cmd.HasAvailableSubCommands())
|
|
|
|
assert.False(t, cmd.HasFlags())
|
|
|
|
assert.Nil(t, cmd.Run)
|
|
assert.Nil(t, cmd.RunE)
|
|
|
|
assert.Nil(t, cmd.PersistentPreRun)
|
|
assert.Nil(t, cmd.PersistentPostRun)
|
|
|
|
allowedCommands := []string{
|
|
"agent",
|
|
"auth",
|
|
"cron",
|
|
"gateway",
|
|
"migrate",
|
|
"model",
|
|
"onboard",
|
|
"skills",
|
|
"status",
|
|
"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)
|
|
}
|
|
}
|