(t *testing.T)
| 408 | } |
| 409 | |
| 410 | func TestMCPNetworkCodemod_PreservesComments(t *testing.T) { |
| 411 | codemod := getMCPNetworkMigrationCodemod() |
| 412 | |
| 413 | content := `--- |
| 414 | on: workflow_dispatch |
| 415 | # MCP server configuration |
| 416 | mcp-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 | |
| 448 | func TestMCPNetworkCodemod_EmptyNetworkAllowed(t *testing.T) { |
| 449 | codemod := getMCPNetworkMigrationCodemod() |
nothing calls this directly
no test coverage detected