(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestGitHubReposToAllowedReposCodemod(t *testing.T) { |
| 13 | codemod := getGitHubReposToAllowedReposCodemod() |
| 14 | |
| 15 | t.Run("renames repos to allowed-repos under tools.github", func(t *testing.T) { |
| 16 | content := `--- |
| 17 | engine: copilot |
| 18 | tools: |
| 19 | github: |
| 20 | mode: remote |
| 21 | toolsets: [default] |
| 22 | repos: "all" |
| 23 | min-integrity: approved |
| 24 | --- |
| 25 | |
| 26 | # Test Workflow |
| 27 | ` |
| 28 | frontmatter := map[string]any{ |
| 29 | "engine": "copilot", |
| 30 | "tools": map[string]any{ |
| 31 | "github": map[string]any{ |
| 32 | "mode": "remote", |
| 33 | "toolsets": []any{"default"}, |
| 34 | "repos": "all", |
| 35 | "min-integrity": "approved", |
| 36 | }, |
| 37 | }, |
| 38 | } |
| 39 | |
| 40 | result, applied, err := codemod.Apply(content, frontmatter) |
| 41 | require.NoError(t, err, "Should not error") |
| 42 | assert.True(t, applied, "Should have applied the codemod") |
| 43 | assert.Contains(t, result, "allowed-repos: \"all\"", "Should rename repos to allowed-repos") |
| 44 | assert.NotContains(t, result, "\n repos: ", "Should not contain old repos: field") |
| 45 | }) |
| 46 | |
| 47 | t.Run("renames repos array to allowed-repos under tools.github", func(t *testing.T) { |
| 48 | content := `--- |
| 49 | engine: copilot |
| 50 | tools: |
| 51 | github: |
| 52 | toolsets: [default] |
| 53 | repos: |
| 54 | - "myorg/*" |
| 55 | - "partner/shared-repo" |
| 56 | min-integrity: approved |
| 57 | --- |
| 58 | |
| 59 | # Test Workflow |
| 60 | ` |
| 61 | frontmatter := map[string]any{ |
| 62 | "engine": "copilot", |
| 63 | "tools": map[string]any{ |
| 64 | "github": map[string]any{ |
| 65 | "toolsets": []any{"default"}, |
| 66 | "repos": []any{"myorg/*", "partner/shared-repo"}, |
| 67 | "min-integrity": "approved", |
| 68 | }, |
| 69 | }, |
nothing calls this directly
no test coverage detected