(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestByokCopilotFeatureRemovalCodemod(t *testing.T) { |
| 14 | codemod := getByokCopilotFeatureRemovalCodemod() |
| 15 | |
| 16 | tests := []struct { |
| 17 | name string |
| 18 | input string |
| 19 | expectApply bool |
| 20 | }{ |
| 21 | { |
| 22 | name: "removes byok-copilot when true", |
| 23 | input: `--- |
| 24 | name: Test Workflow |
| 25 | engine: copilot |
| 26 | features: |
| 27 | byok-copilot: true |
| 28 | mcp-gateway: true |
| 29 | --- |
| 30 | # Test workflow`, |
| 31 | expectApply: true, |
| 32 | }, |
| 33 | { |
| 34 | name: "removes byok-copilot when false", |
| 35 | input: `--- |
| 36 | name: Test Workflow |
| 37 | engine: copilot |
| 38 | features: |
| 39 | byok-copilot: false |
| 40 | --- |
| 41 | # Test workflow`, |
| 42 | expectApply: true, |
| 43 | }, |
| 44 | { |
| 45 | name: "does not modify when byok-copilot is absent", |
| 46 | input: `--- |
| 47 | name: Test Workflow |
| 48 | engine: copilot |
| 49 | features: |
| 50 | mcp-gateway: true |
| 51 | --- |
| 52 | # Test workflow`, |
| 53 | expectApply: false, |
| 54 | }, |
| 55 | } |
| 56 | |
| 57 | for _, tt := range tests { |
| 58 | t.Run(tt.name, func(t *testing.T) { |
| 59 | result, err := parser.ExtractFrontmatterFromContent(tt.input) |
| 60 | require.NoError(t, err, "Failed to parse test input frontmatter") |
| 61 | |
| 62 | output, applied, err := codemod.Apply(tt.input, result.Frontmatter) |
| 63 | require.NoError(t, err, "Codemod apply should not error") |
| 64 | assert.Equal(t, tt.expectApply, applied, "Applied status mismatch") |
| 65 | |
| 66 | if tt.expectApply { |
| 67 | assert.NotContains(t, output, "byok-copilot:", "Codemod should remove deprecated byok-copilot flag") |
| 68 | } else { |
| 69 | assert.Equal(t, tt.input, output, "Output should be unchanged when codemod does not apply") |
| 70 | } |
nothing calls this directly
no test coverage detected