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

Function Test_getSelectedReadme

pkg/cmd/extension/browse/browse_test.go:25–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func Test_getSelectedReadme(t *testing.T) {
26 reg := httpmock.Registry{}
27 defer reg.Verify(t)
28
29 content := base64.StdEncoding.EncodeToString([]byte("lol"))
30
31 reg.Register(
32 httpmock.REST("GET", "repos/cli/gh-cool/readme"),
33 httpmock.JSONResponse(view.RepoReadme{Content: content}))
34
35 client := &http.Client{Transport: &reg}
36
37 rg := newReadmeGetter(client, time.Second)
38 opts := ExtBrowseOpts{
39 Rg: rg,
40 }
41 readme := tview.NewTextView()
42 ui := uiRegistry{
43 List: tview.NewList(),
44 }
45 extEntries := []extEntry{
46 {
47 Name: "gh-cool",
48 FullName: "cli/gh-cool",
49 Installed: false,
50 Official: true,
51 description: "it's just cool ok",
52 },
53 {
54 Name: "gh-screensaver",
55 FullName: "vilmibm/gh-screensaver",
56 Installed: true,
57 Official: false,
58 description: "animations in your terminal",
59 },
60 }
61 el := newExtList(opts, ui, extEntries)
62
63 content, err := getSelectedReadme(opts, readme, el)
64 assert.NoError(t, err)
65 assert.Contains(t, content, "lol")
66}
67
68func Test_getExtensionRepos(t *testing.T) {
69 reg := httpmock.Registry{}

Callers

nothing calls this directly

Calls 8

VerifyMethod · 0.95
RegisterMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
newReadmeGetterFunction · 0.85
newExtListFunction · 0.85
getSelectedReadmeFunction · 0.85
ContainsMethod · 0.80

Tested by

no test coverage detected