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

Function TestFixCommand_NetworkFirewallMigration

pkg/cli/fix_command_test.go:167–230  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

165}
166
167func TestFixCommand_NetworkFirewallMigration(t *testing.T) {
168 // Create a temporary directory for test files
169 tmpDir := t.TempDir()
170 workflowFile := filepath.Join(tmpDir, "test-workflow.md")
171
172 // Create a workflow with deprecated network.firewall field
173 content := `---
174on:
175 workflow_dispatch:
176
177network:
178 allowed:
179 - "*.example.com"
180 firewall: null
181
182permissions:
183 contents: read
184---
185
186# Test Workflow
187
188This is a test workflow.
189`
190
191 if err := os.WriteFile(workflowFile, []byte(content), 0644); err != nil {
192 t.Fatalf("Failed to create test file: %v", err)
193 }
194
195 // Get the firewall migration codemod
196 firewallCodemod := getCodemodByID("network-firewall-migration")
197 if firewallCodemod == nil {
198 t.Fatal("network-firewall-migration codemod not found")
199 }
200
201 // Process the file
202 fixed, _, err := processWorkflowFileWithInfo(workflowFile, []Codemod{*firewallCodemod}, true, false)
203 if err != nil {
204 t.Fatalf("Failed to process workflow file: %v", err)
205 }
206
207 if !fixed {
208 t.Error("Expected file to be fixed, but no changes were made")
209 }
210
211 // Read the updated content
212 updatedContent, err := os.ReadFile(workflowFile)
213 if err != nil {
214 t.Fatalf("Failed to read updated file: %v", err)
215 }
216
217 updatedStr := string(updatedContent)
218
219 // Verify the change
220 if strings.Contains(updatedStr, "firewall:") {
221 t.Error("Expected firewall field to be removed, but it still exists")
222 }
223
224 if !strings.Contains(updatedStr, "sandbox:") {

Callers

nothing calls this directly

Calls 4

getCodemodByIDFunction · 0.85
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected