MCPcopy Create free account
hub / github.com/github/gh-aw / TestGitHubReposToAllowedReposCodemod

Function TestGitHubReposToAllowedReposCodemod

pkg/cli/codemod_github_repos_test.go:12–241  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func 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 := `---
17engine: copilot
18tools:
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 := `---
49engine: copilot
50tools:
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 },

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45

Tested by

no test coverage detected