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

Function TestManager_list_includeMetadata

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

Source from the content-addressed store, hash-verified

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