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

Function TestBrowseModelShowsBrowserFailure

pkg/cmd/extension/browse/model_test.go:593–615  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

591}
592
593func TestBrowseModelShowsBrowserFailure(t *testing.T) {
594 t.Parallel()
595
596 // Given the selected extension repository cannot be opened in a browser
597 browser := &browserStub{err: errors.New("browser unavailable")}
598 model := newBrowseModel(ExtBrowseOpts{
599 Browser: browser,
600 }, []extEntry{
601 {
602 FullName: "cli/gh-cool",
603 URL: "https://github.com/cli/gh-cool",
604 },
605 })
606
607 // When the user presses w and the browser command completes
608 cmd := updateBrowseModel(t, model, keyPress('w'))
609 require.NotNil(t, cmd)
610 updateBrowseModel(t, model, cmd())
611
612 // Then the attempted URL and visible failure identify the selected extension
613 assert.Equal(t, "https://github.com/cli/gh-cool", browser.url)
614 assert.Contains(t, model.View().Content, "could not open browser for 'https://github.com/cli/gh-cool'")
615}
616
617func TestBrowseModelClearsTransientStatusOnNextInteraction(t *testing.T) {
618 t.Parallel()

Callers

nothing calls this directly

Calls 6

newBrowseModelFunction · 0.85
updateBrowseModelFunction · 0.85
keyPressFunction · 0.85
EqualMethod · 0.80
ContainsMethod · 0.80
ViewMethod · 0.65

Tested by

no test coverage detected