(t *testing.T)
| 26 | } |
| 27 | |
| 28 | func 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 | |
| 54 | func TestGitFallbackRequiresNonEmptyRef(t *testing.T) { |
| 55 | t.Run("all files fallback validates ref", func(t *testing.T) { |
nothing calls this directly
no test coverage detected