MCPcopy
hub / github.com/cli/cli / TestManager_list_includeMetadata

Function TestManager_list_includeMetadata

pkg/cmd/extension/manager_test.go:100–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

98}
99
100func TestManager_list_includeMetadata(t *testing.T) {
101 dataDir := t.TempDir()
102 updateDir := t.TempDir()
103
104 assert.NoError(t, stubBinaryExtension(
105 filepath.Join(dataDir, "extensions", "gh-bin-ext"),
106 binManifest{
107 Owner: "owner",
108 Name: "gh-bin-ext",
109 Host: "example.com",
110 Tag: "v1.0.1",
111 }))
112
113 reg := httpmock.Registry{}
114 defer reg.Verify(t)
115 client := http.Client{Transport: &reg}
116
117 reg.Register(
118 httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"),
119 httpmock.JSONResponse(
120 release{
121 Tag: "v1.0.2",
122 Assets: []releaseAsset{
123 {
124 Name: "gh-bin-ext-windows-amd64",
125 APIURL: "https://example.com/release/cool2",
126 },
127 },
128 }))
129
130 m := newTestManager(dataDir, updateDir, &client, nil, nil)
131
132 exts, err := m.list(true)
133 assert.NoError(t, err)
134 assert.Equal(t, 1, len(exts))
135 assert.Equal(t, "bin-ext", exts[0].Name())
136 assert.True(t, exts[0].UpdateAvailable())
137 assert.Equal(t, "https://example.com/owner/gh-bin-ext", exts[0].URL())
138}
139
140func TestManager_Dispatch(t *testing.T) {
141 dataDir := t.TempDir()

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
RegisterMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
stubBinaryExtensionFunction · 0.85
newTestManagerFunction · 0.85
JoinMethod · 0.80
listMethod · 0.80
EqualMethod · 0.80
NameMethod · 0.65
UpdateAvailableMethod · 0.65
URLMethod · 0.65

Tested by

no test coverage detected