MCPcopy Create free account
hub / github.com/cli/cli / TestPreviewRun_RenderLimits

Function TestPreviewRun_RenderLimits

pkg/cmd/skills/preview/preview_test.go:733–906  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

731}
732
733func TestPreviewRun_RenderLimits(t *testing.T) {
734 skillContent := heredoc.Doc(`
735 ---
736 name: my-skill
737 description: test
738 ---
739 # My Skill
740 `)
741 encodedSkill := base64.StdEncoding.EncodeToString([]byte(skillContent))
742
743 // Helper: build a tree JSON with N extra files (beyond SKILL.md)
744 buildTree := func(n int) string {
745 entries := []string{
746 `{"path": "skills/my-skill", "type": "tree", "sha": "treeSHA"}`,
747 `{"path": "skills/my-skill/SKILL.md", "type": "blob", "sha": "blobSKILL"}`,
748 }
749 for i := range n {
750 entries = append(entries, fmt.Sprintf(
751 `{"path": "skills/my-skill/file%03d.txt", "type": "blob", "sha": "blob%03d"}`, i, i))
752 }
753 return fmt.Sprintf(`{"sha":"abc123","truncated":false,"tree":[%s]}`,
754 strings.Join(entries, ","))
755 }
756
757 // Helper: build subtree JSON with N extra files
758 buildSubtree := func(n int, sizes []int) string {
759 entries := []string{
760 `{"path": "SKILL.md", "type": "blob", "sha": "blobSKILL", "size": 50}`,
761 }
762 for i := range n {
763 sz := 10
764 if i < len(sizes) {
765 sz = sizes[i]
766 }
767 entries = append(entries, fmt.Sprintf(
768 `{"path": "file%03d.txt", "type": "blob", "sha": "blob%03d", "size": %d}`, i, i, sz))
769 }
770 return fmt.Sprintf(`{"tree":[%s]}`, strings.Join(entries, ","))
771 }
772
773 // Common stubs for resolve + discover
774 registerBase := func(reg *httpmock.Registry, treeJSON, subtreeJSON string) {
775 reg.Register(
776 httpmock.REST("GET", "repos/monalisa/skills-repo/releases/latest"),
777 httpmock.StringResponse(`{"tag_name": "v1.0.0"}`),
778 )
779 reg.Register(
780 httpmock.REST("GET", "repos/monalisa/skills-repo/git/ref/tags%2Fv1.0.0"),
781 httpmock.StringResponse(`{"object": {"sha": "abc123", "type": "commit"}}`),
782 )
783 reg.Register(
784 httpmock.REST("GET", "repos/monalisa/skills-repo/git/trees/abc123"),
785 httpmock.StringResponse(treeJSON),
786 )
787 reg.Register(
788 httpmock.REST("GET", "repos/monalisa/skills-repo/git/trees/treeSHA"),
789 httpmock.StringResponse(subtreeJSON),
790 )

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
StatusStringResponseFunction · 0.92
buildTreeFunction · 0.85
previewRunFunction · 0.85
JoinMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80

Tested by

no test coverage detected