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

Function TestFirewallLogLevelInCopilotEngine

pkg/workflow/firewall_log_level_test.go:36–114  ·  view source on GitHub ↗

TestFirewallLogLevelInCopilotEngine tests that the log-level is used in the copilot engine

(t *testing.T)

Source from the content-addressed store, hash-verified

34
35// TestFirewallLogLevelInCopilotEngine tests that the log-level is used in the copilot engine
36func TestFirewallLogLevelInCopilotEngine(t *testing.T) {
37 t.Run("default log-level is 'info' when not specified", func(t *testing.T) {
38 workflowData := &WorkflowData{
39 Name: "test-workflow",
40 EngineConfig: &EngineConfig{
41 ID: "copilot",
42 },
43 NetworkPermissions: &NetworkPermissions{
44 Firewall: &FirewallConfig{
45 Enabled: true,
46 },
47 },
48 }
49
50 engine := NewCopilotEngine()
51 steps := engine.GetExecutionSteps(workflowData, "test.log")
52
53 stepContent := requireCopilotExecutionStep(t, steps)
54
55 // Check that the command contains --log-level info (default)
56 if !strings.Contains(stepContent, "--log-level info") {
57 t.Errorf("Expected command to contain '--log-level info' (default), got:\n%s", stepContent)
58 }
59 })
60
61 t.Run("custom log-level is used when specified", func(t *testing.T) {
62 workflowData := &WorkflowData{
63 Name: "test-workflow",
64 EngineConfig: &EngineConfig{
65 ID: "copilot",
66 },
67 NetworkPermissions: &NetworkPermissions{
68 Firewall: &FirewallConfig{
69 Enabled: true,
70 LogLevel: "debug",
71 },
72 },
73 }
74
75 engine := NewCopilotEngine()
76 steps := engine.GetExecutionSteps(workflowData, "test.log")
77
78 stepContent := requireCopilotExecutionStep(t, steps)
79
80 // Check that the command contains --log-level debug
81 if !strings.Contains(stepContent, "--log-level debug") {
82 t.Errorf("Expected command to contain '--log-level debug', got:\n%s", stepContent)
83 }
84 })
85
86 t.Run("log-level can be set to different values", func(t *testing.T) {
87 logLevels := []string{"debug", "info", "warn", "error"}
88
89 for _, level := range logLevels {
90 workflowData := &WorkflowData{
91 Name: "test-workflow",
92 EngineConfig: &EngineConfig{
93 ID: "copilot",

Callers

nothing calls this directly

Calls 5

GetExecutionStepsMethod · 0.95
NewCopilotEngineFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected