MCPcopy Create free account
hub / github.com/github/gh-aw / TestEngineArgsFieldExtraction

Function TestEngineArgsFieldExtraction

pkg/workflow/engine_args_test.go:10–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestEngineArgsFieldExtraction(t *testing.T) {
11 compiler := NewCompiler()
12
13 t.Run("Engine args field extraction with []any", func(t *testing.T) {
14 frontmatter := map[string]any{
15 "engine": map[string]any{
16 "id": "copilot",
17 "args": []any{"--add-dir", "/"},
18 },
19 }
20
21 _, config := compiler.ExtractEngineConfig(frontmatter)
22 if config == nil {
23 t.Fatal("Expected config to be non-nil")
24 }
25 if config.ID != "copilot" {
26 t.Errorf("Expected ID 'copilot', got %s", config.ID)
27 }
28 if len(config.Args) != 2 {
29 t.Errorf("Expected 2 args, got %d", len(config.Args))
30 }
31 if config.Args[0] != "--add-dir" || config.Args[1] != "/" {
32 t.Errorf("Expected [--add-dir /], got %v", config.Args)
33 }
34 })
35
36 t.Run("Engine args field extraction with []string", func(t *testing.T) {
37 frontmatter := map[string]any{
38 "engine": map[string]any{
39 "id": "copilot",
40 "args": []string{"--verbose", "--debug"},
41 },
42 }
43
44 _, config := compiler.ExtractEngineConfig(frontmatter)
45 if config == nil {
46 t.Fatal("Expected config to be non-nil")
47 }
48 if len(config.Args) != 2 {
49 t.Errorf("Expected 2 args, got %d", len(config.Args))
50 }
51 if config.Args[0] != "--verbose" || config.Args[1] != "--debug" {
52 t.Errorf("Expected [--verbose --debug], got %v", config.Args)
53 }
54 })
55
56 t.Run("Engine without args field", func(t *testing.T) {
57 frontmatter := map[string]any{
58 "engine": map[string]any{
59 "id": "copilot",
60 },
61 }
62
63 _, config := compiler.ExtractEngineConfig(frontmatter)
64 if config == nil {
65 t.Fatal("Expected config to be non-nil")
66 }
67 if config.Args != nil {

Callers

nothing calls this directly

Calls 4

ExtractEngineConfigMethod · 0.95
NewCompilerFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected