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