(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestDIFCProxyToIntegrityProxyCodemod(t *testing.T) { |
| 13 | codemod := getDIFCProxyToIntegrityProxyCodemod() |
| 14 | |
| 15 | t.Run("removes features.difc-proxy: true (no-op since proxy is now default)", func(t *testing.T) { |
| 16 | content := `--- |
| 17 | engine: copilot |
| 18 | features: |
| 19 | difc-proxy: true |
| 20 | tools: |
| 21 | github: |
| 22 | min-integrity: approved |
| 23 | --- |
| 24 | |
| 25 | # Test Workflow |
| 26 | ` |
| 27 | frontmatter := map[string]any{ |
| 28 | "engine": "copilot", |
| 29 | "features": map[string]any{ |
| 30 | "difc-proxy": true, |
| 31 | }, |
| 32 | "tools": map[string]any{ |
| 33 | "github": map[string]any{ |
| 34 | "min-integrity": "approved", |
| 35 | }, |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | result, applied, err := codemod.Apply(content, frontmatter) |
| 40 | require.NoError(t, err, "Should not error") |
| 41 | assert.True(t, applied, "Should have applied the codemod") |
| 42 | assert.NotContains(t, result, "difc-proxy", "Should remove features.difc-proxy") |
| 43 | assert.NotContains(t, result, "integrity-proxy", "Should not add integrity-proxy when was true") |
| 44 | assert.Contains(t, result, "min-integrity: approved", "Should preserve min-integrity") |
| 45 | }) |
| 46 | |
| 47 | t.Run("removes features.difc-proxy: false and adds tools.github.integrity-proxy: false", func(t *testing.T) { |
| 48 | content := `--- |
| 49 | engine: copilot |
| 50 | features: |
| 51 | difc-proxy: false |
| 52 | tools: |
| 53 | github: |
| 54 | min-integrity: approved |
| 55 | --- |
| 56 | |
| 57 | # Test Workflow |
| 58 | ` |
| 59 | frontmatter := map[string]any{ |
| 60 | "engine": "copilot", |
| 61 | "features": map[string]any{ |
| 62 | "difc-proxy": false, |
| 63 | }, |
| 64 | "tools": map[string]any{ |
| 65 | "github": map[string]any{ |
| 66 | "min-integrity": "approved", |
| 67 | }, |
| 68 | }, |
| 69 | } |
nothing calls this directly
no test coverage detected