(t *testing.T)
| 519 | } |
| 520 | |
| 521 | func 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 |
nothing calls this directly
no test coverage detected