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

Function TestBuildContentsAPIPath

pkg/parser/remote_fetch_test.go:28–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestBuildContentsAPIPath(t *testing.T) {
29 t.Run("escapes refs with reserved query chars", func(t *testing.T) {
30 got := buildContentsAPIPath("owner", "repo", ".github/workflows/demo.md", "release+candidate#1")
31 want := "repos/owner/repo/contents/.github/workflows/demo.md?ref=release%2Bcandidate%231"
32 if got != want {
33 t.Fatalf("buildContentsAPIPath() = %q, want %q", got, want)
34 }
35 })
36
37 t.Run("keeps plain refs readable", func(t *testing.T) {
38 got := buildContentsAPIPath("owner", "repo", ".github/workflows/demo.md", "main")
39 want := "repos/owner/repo/contents/.github/workflows/demo.md?ref=main"
40 if got != want {
41 t.Fatalf("buildContentsAPIPath() = %q, want %q", got, want)
42 }
43 })
44
45 t.Run("escapes path segments with reserved chars", func(t *testing.T) {
46 got := buildContentsAPIPath("owner", "repo", "skills/path with spaces/file#100%.md", "main")
47 want := "repos/owner/repo/contents/skills/path%20with%20spaces/file%23100%25.md?ref=main"
48 if got != want {
49 t.Fatalf("buildContentsAPIPath() = %q, want %q", got, want)
50 }
51 })
52}
53
54func TestGitFallbackRequiresNonEmptyRef(t *testing.T) {
55 t.Run("all files fallback validates ref", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

buildContentsAPIPathFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected