TestEngineStepsToTopLevelCodemod_NoOp tests cases where the codemod should not apply
(t *testing.T)
| 22 | |
| 23 | // TestEngineStepsToTopLevelCodemod_NoOp tests cases where the codemod should not apply |
| 24 | func TestEngineStepsToTopLevelCodemod_NoOp(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | content string |
| 28 | frontmatter map[string]any |
| 29 | }{ |
| 30 | { |
| 31 | name: "no engine field", |
| 32 | content: `--- |
| 33 | on: push |
| 34 | --- |
| 35 | |
| 36 | # Test workflow`, |
| 37 | frontmatter: map[string]any{ |
| 38 | "on": "push", |
| 39 | }, |
| 40 | }, |
| 41 | { |
| 42 | name: "engine is a string", |
| 43 | content: `--- |
| 44 | on: push |
| 45 | engine: claude |
| 46 | --- |
| 47 | |
| 48 | # Test workflow`, |
| 49 | frontmatter: map[string]any{ |
| 50 | "on": "push", |
| 51 | "engine": "claude", |
| 52 | }, |
| 53 | }, |
| 54 | { |
| 55 | name: "engine object without steps", |
| 56 | content: `--- |
| 57 | on: push |
| 58 | engine: |
| 59 | id: claude |
| 60 | model: claude-3-5-sonnet |
| 61 | --- |
| 62 | |
| 63 | # Test workflow`, |
| 64 | frontmatter: map[string]any{ |
| 65 | "on": "push", |
| 66 | "engine": map[string]any{ |
| 67 | "id": "claude", |
| 68 | "model": "claude-3-5-sonnet", |
| 69 | }, |
| 70 | }, |
| 71 | }, |
| 72 | } |
| 73 | |
| 74 | for _, tt := range tests { |
| 75 | t.Run(tt.name, func(t *testing.T) { |
| 76 | codemod := getEngineStepsToTopLevelCodemod() |
| 77 | result, applied, err := codemod.Apply(tt.content, tt.frontmatter) |
| 78 | require.NoError(t, err) |
| 79 | assert.False(t, applied, "Should not apply") |
| 80 | assert.Equal(t, tt.content, result, "Content should be unchanged") |
| 81 | }) |
nothing calls this directly
no test coverage detected