fix package

This commit is contained in:
LPF
2026-03-10 00:33:23 +08:00
parent e9a47ac02a
commit c18fdb690e
85 changed files with 381 additions and 316 deletions

40
cmd/cmd_onboard_test.go Normal file
View File

@@ -0,0 +1,40 @@
package main
import (
"testing"
"github.com/YspCoder/clawgo/pkg/config"
)
func TestParseOnboardOptionsSyncWebUI(t *testing.T) {
t.Parallel()
opts := parseOnboardOptions([]string{"--sync-webui"})
if !opts.syncWebUIOnly {
t.Fatalf("expected sync webui option to be enabled")
}
}
func TestEnsureConfigOnboardGeneratesGatewayToken(t *testing.T) {
t.Parallel()
configPath := t.TempDir() + "/config.json"
cfg := config.DefaultConfig()
cfg.Gateway.Token = ""
state, err := ensureConfigOnboard(configPath, cfg)
if err != nil {
t.Fatalf("ensureConfigOnboard failed: %v", err)
}
if state != "created" {
t.Fatalf("unexpected state: %s", state)
}
loaded, err := config.LoadConfig(configPath)
if err != nil {
t.Fatalf("load config failed: %v", err)
}
if loaded.Gateway.Token == "" {
t.Fatalf("expected gateway token to be generated")
}
}