MCPcopy
hub / github.com/cli/cli / TestPreviewRun_ShowsFileTree

Function TestPreviewRun_ShowsFileTree

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

Source from the content-addressed store, hash-verified

519}
520
521func TestPreviewRun_ShowsFileTree(t *testing.T) {
522 skillContent := heredoc.Doc(`
523 ---
524 name: my-skill
525 description: test
526 ---
527 # My Skill
528 Body.
529 `)
530 encodedContent := base64.StdEncoding.EncodeToString([]byte(skillContent))
531
532 scriptContent := "#!/bin/bash\necho hello"
533 encodedScript := base64.StdEncoding.EncodeToString([]byte(scriptContent))
534
535 makeReg := func() *httpmock.Registry {
536 reg := &httpmock.Registry{}
537 reg.Register(
538 httpmock.REST("GET", "repos/owner/repo/releases/latest"),
539 httpmock.StringResponse(`{"tag_name": "v1.0.0"}`),
540 )
541 reg.Register(
542 httpmock.REST("GET", "repos/owner/repo/git/ref/tags/v1.0.0"),
543 httpmock.StringResponse(`{"object": {"sha": "abc123", "type": "commit"}}`),
544 )
545 reg.Register(
546 httpmock.REST("GET", "repos/owner/repo/git/trees/abc123"),
547 httpmock.StringResponse(`{
548 "sha": "abc123",
549 "truncated": false,
550 "tree": [
551 {"path": "skills/my-skill", "type": "tree", "sha": "treeSHA"},
552 {"path": "skills/my-skill/SKILL.md", "type": "blob", "sha": "blobSKILL"},
553 {"path": "skills/my-skill/scripts", "type": "tree", "sha": "treeScripts"},
554 {"path": "skills/my-skill/scripts/run.sh", "type": "blob", "sha": "blobScript"}
555 ]
556 }`),
557 )
558 reg.Register(
559 httpmock.REST("GET", "repos/owner/repo/git/trees/treeSHA"),
560 httpmock.StringResponse(`{
561 "tree": [
562 {"path": "SKILL.md", "type": "blob", "sha": "blobSKILL", "size": 50},
563 {"path": "scripts", "type": "tree", "sha": "treeScripts"},
564 {"path": "scripts/run.sh", "type": "blob", "sha": "blobScript", "size": 20}
565 ]
566 }`),
567 )
568 reg.Register(
569 httpmock.REST("GET", "repos/owner/repo/git/blobs/blobSKILL"),
570 httpmock.StringResponse(`{"sha": "blobSKILL", "content": "`+encodedContent+`", "encoding": "base64"}`),
571 )
572 reg.Register(
573 httpmock.REST("GET", "repos/owner/repo/git/blobs/blobScript"),
574 httpmock.StringResponse(`{"sha": "blobScript", "content": "`+encodedScript+`", "encoding": "base64"}`),
575 )
576 return reg
577 }
578

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
previewRunFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetColorEnabledMethod · 0.80
EqualMethod · 0.80
ContainsMethod · 0.80

Tested by

no test coverage detected