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

Function TestMCPNetworkCodemod_PreservesComments

pkg/cli/codemod_mcp_network_test.go:410–446  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

408}
409
410func TestMCPNetworkCodemod_PreservesComments(t *testing.T) {
411 codemod := getMCPNetworkMigrationCodemod()
412
413 content := `---
414on: workflow_dispatch
415# MCP server configuration
416mcp-servers:
417 my-server:
418 container: my-image
419 # Network configuration (deprecated)
420 network:
421 allowed:
422 - example.com
423---
424
425# Test`
426
427 frontmatter := map[string]any{
428 "on": "workflow_dispatch",
429 "mcp-servers": map[string]any{
430 "my-server": map[string]any{
431 "container": "my-image",
432 "network": map[string]any{
433 "allowed": []any{"example.com"},
434 },
435 },
436 },
437 }
438
439 result, applied, err := codemod.Apply(content, frontmatter)
440
441 require.NoError(t, err)
442 assert.True(t, applied)
443 assert.Contains(t, result, "# MCP server configuration")
444 // Comments at the same level as the removed field are preserved (they're siblings, not children)
445 assert.Contains(t, result, "# Network configuration (deprecated)")
446}
447
448func TestMCPNetworkCodemod_EmptyNetworkAllowed(t *testing.T) {
449 codemod := getMCPNetworkMigrationCodemod()

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected