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

Function TestFetchDescriptionsConcurrent

internal/skills/discovery/discovery_test.go:1756–1803  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1754}
1755
1756func TestFetchDescriptionsConcurrent(t *testing.T) {
1757 tests := []struct {
1758 name string
1759 skills []Skill
1760 stubs func(*httpmock.Registry)
1761 wantDescs []string
1762 }{
1763 {
1764 name: "fetches descriptions for skills without one",
1765 skills: []Skill{
1766 {Name: "code-review", BlobSHA: "blob1"},
1767 {Name: "issue-triage", Description: "already set"},
1768 },
1769 stubs: func(reg *httpmock.Registry) {
1770 reg.Register(
1771 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/blobs/blob1"),
1772 httpmock.JSONResponse(map[string]interface{}{
1773 "sha": "blob1", "encoding": "base64",
1774 "content": "LS0tCm5hbWU6IGNvZGUtcmV2aWV3CmRlc2NyaXB0aW9uOiBSZXZpZXdzIFBScwotLS0KIyBUZXN0",
1775 }))
1776 },
1777 wantDescs: []string{"Reviews PRs", "already set"},
1778 },
1779 {
1780 name: "no-op when all descriptions set",
1781 skills: []Skill{
1782 {Name: "code-review", Description: "set"},
1783 },
1784 stubs: func(reg *httpmock.Registry) {},
1785 wantDescs: []string{"set"},
1786 },
1787 }
1788 for _, tt := range tests {
1789 t.Run(tt.name, func(t *testing.T) {
1790 reg := &httpmock.Registry{}
1791 defer reg.Verify(t)
1792 tt.stubs(reg)
1793 client := api.NewClientFromHTTP(&http.Client{Transport: reg})
1794
1795 FetchDescriptionsConcurrent(client, "github.com", "monalisa", "octocat-skills", tt.skills, nil)
1796 var descs []string
1797 for _, s := range tt.skills {
1798 descs = append(descs, s.Description)
1799 }
1800 assert.Equal(t, tt.wantDescs, descs)
1801 })
1802 }
1803}

Callers

nothing calls this directly

Calls 8

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
NewClientFromHTTPFunction · 0.92
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected