- Add onshot.go and persistent.go for distinct CLI modes - Update cli.go, factory_internal_test.go, cli_test.go - Update configs/edge.yaml and packages/config - Update READMEs for edge and node apps
116 lines
2.6 KiB
Go
116 lines
2.6 KiB
Go
package adapters
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"google.golang.org/protobuf/types/known/structpb"
|
|
)
|
|
|
|
func TestCLIConfFromStruct_ProfileRuntimeOptions(t *testing.T) {
|
|
st, err := structpb.NewStruct(map[string]any{
|
|
"profiles": map[string]any{
|
|
"claude": map[string]any{
|
|
"command": "claude",
|
|
"args": []any{"-p"},
|
|
"env": []any{},
|
|
"persistent": false,
|
|
"terminal": false,
|
|
},
|
|
},
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("structpb: %v", err)
|
|
}
|
|
|
|
cfg := cliConfFromStruct(st)
|
|
|
|
prof, ok := cfg.Profiles["claude"]
|
|
if !ok {
|
|
t.Fatal("expected claude profile")
|
|
}
|
|
if prof.Command != "claude" {
|
|
t.Fatalf("command: got %q", prof.Command)
|
|
}
|
|
if len(prof.Args) != 1 || prof.Args[0] != "-p" {
|
|
t.Fatalf("args: got %#v", prof.Args)
|
|
}
|
|
}
|
|
|
|
func TestCLIConfFromStruct_ClaudeHeadlessBypassProfile(t *testing.T) {
|
|
st, err := structpb.NewStruct(map[string]any{
|
|
"profiles": map[string]any{
|
|
"claude": map[string]any{
|
|
"command": "claude",
|
|
"args": []any{"-p", "--dangerously-skip-permissions"},
|
|
"env": []any{},
|
|
"persistent": false,
|
|
"terminal": false,
|
|
},
|
|
},
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("structpb: %v", err)
|
|
}
|
|
|
|
cfg := cliConfFromStruct(st)
|
|
|
|
prof, ok := cfg.Profiles["claude"]
|
|
if !ok {
|
|
t.Fatal("expected claude profile")
|
|
}
|
|
if prof.Command != "claude" {
|
|
t.Fatalf("command: got %q", prof.Command)
|
|
}
|
|
if len(prof.Args) != 2 || prof.Args[0] != "-p" || prof.Args[1] != "--dangerously-skip-permissions" {
|
|
t.Fatalf("args: got %#v", prof.Args)
|
|
}
|
|
if prof.Persistent {
|
|
t.Fatal("expected persistent=false")
|
|
}
|
|
if prof.Terminal {
|
|
t.Fatal("expected terminal=false")
|
|
}
|
|
}
|
|
|
|
func TestCLIConfFromStruct_GeminiHeadlessYoloProfile(t *testing.T) {
|
|
st, err := structpb.NewStruct(map[string]any{
|
|
"profiles": map[string]any{
|
|
"gemini": map[string]any{
|
|
"command": "gemini",
|
|
"args": []any{"-p", "--approval-mode", "yolo"},
|
|
"env": []any{},
|
|
"persistent": false,
|
|
"terminal": false,
|
|
},
|
|
},
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("structpb: %v", err)
|
|
}
|
|
|
|
cfg := cliConfFromStruct(st)
|
|
|
|
prof, ok := cfg.Profiles["gemini"]
|
|
if !ok {
|
|
t.Fatal("expected gemini profile")
|
|
}
|
|
if prof.Command != "gemini" {
|
|
t.Fatalf("command: got %q", prof.Command)
|
|
}
|
|
if len(prof.Args) != 3 || prof.Args[0] != "-p" || prof.Args[1] != "--approval-mode" || prof.Args[2] != "yolo" {
|
|
t.Fatalf("args: got %#v", prof.Args)
|
|
}
|
|
if prof.Persistent {
|
|
t.Fatal("expected persistent=false")
|
|
}
|
|
if prof.Terminal {
|
|
t.Fatal("expected terminal=false")
|
|
}
|
|
}
|
|
|
|
func TestCLIConfFromStruct_NilSettings(t *testing.T) {
|
|
cfg := cliConfFromStruct(nil)
|
|
if cfg.Enabled {
|
|
t.Fatal("expected enabled=false for nil settings")
|
|
}
|
|
}
|