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

Function TestResolveIncludePath_DotGithubRepo

pkg/parser/frontmatter_utils_test.go:244–332  ·  view source on GitHub ↗

TestResolveIncludePath_DotGithubRepo tests import path resolution when the repository itself is named ".github" (e.g. an org's `org/.github` repository). In that case the on-disk layout is /.github/.github/workflows/ and the traversal logic must correctly treat the inner ".github" directory

(t *testing.T)

Source from the content-addressed store, hash-verified

242// correctly treat the inner ".github" directory as the special folder and
243// <parent>/.github/ as the repository root.
244func TestResolveIncludePath_DotGithubRepo(t *testing.T) {
245 tempDir, err := os.MkdirTemp("", "test_resolve_dotgithub_repo")
246 require.NoError(t, err, "should create temp dir")
247 defer os.RemoveAll(tempDir)
248
249 // Simulate a repo whose name is ".github": the repo root is <tempDir>/.github
250 // and the GitHub Actions folder lives at <tempDir>/.github/.github/workflows/.
251 dotGithubRepoRoot := filepath.Join(tempDir, ".github")
252 workflowsDir := filepath.Join(dotGithubRepoRoot, ".github", "workflows")
253 agentsDir := filepath.Join(dotGithubRepoRoot, ".github", "agents")
254 dotAgentsDir := filepath.Join(dotGithubRepoRoot, ".agents")
255
256 for _, dir := range []string{workflowsDir, agentsDir, dotAgentsDir} {
257 require.NoError(t, os.MkdirAll(dir, 0755), "should create dir %s", dir)
258 }
259
260 workflowFile := filepath.Join(workflowsDir, "workflow.md")
261 agentFile := filepath.Join(agentsDir, "planner.md")
262 dotAgentFile := filepath.Join(dotAgentsDir, "agent.md")
263
264 require.NoError(t, os.WriteFile(workflowFile, []byte("workflow"), 0644), "should write workflow file")
265 require.NoError(t, os.WriteFile(agentFile, []byte("planner"), 0644), "should write agent file")
266 require.NoError(t, os.WriteFile(dotAgentFile, []byte("dot-agents"), 0644), "should write .agents file")
267
268 tests := []struct {
269 name string
270 filePath string
271 baseDir string
272 expected string
273 wantErr bool
274 }{
275 {
276 name: "relative path still resolves within workflows dir",
277 filePath: "workflow.md",
278 baseDir: workflowsDir,
279 expected: workflowFile,
280 },
281 {
282 name: "dotgithub-prefixed path resolves from repo root inside .github repo",
283 filePath: ".github/agents/planner.md",
284 baseDir: workflowsDir,
285 expected: agentFile,
286 },
287 {
288 name: "slash-dotgithub-prefixed path resolves from repo root inside .github repo",
289 filePath: "/.github/agents/planner.md",
290 baseDir: workflowsDir,
291 expected: agentFile,
292 },
293 {
294 name: "slash-dotagents-prefixed path resolves from repo root inside .github repo",
295 filePath: "/.agents/agent.md",
296 baseDir: workflowsDir,
297 expected: dotAgentFile,
298 },
299 {
300 name: "slash-prefixed path outside .github or .agents is rejected inside .github repo",
301 filePath: "/agents/agent.md",

Callers

nothing calls this directly

Calls 3

ResolveIncludePathFunction · 0.70
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected