(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func 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: ®} |
| 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 | |
| 68 | func Test_getExtensionRepos(t *testing.T) { |
| 69 | reg := httpmock.Registry{} |
nothing calls this directly
no test coverage detected