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

Function TestManager_Dispatch_binary

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

Source from the content-addressed store, hash-verified

174}
175
176func TestManager_Dispatch_binary(t *testing.T) {
177 dataDir := t.TempDir()
178 updateDir := t.TempDir()
179 extPath := filepath.Join(dataDir, "extensions", "gh-hello")
180 exePath := filepath.Join(extPath, "gh-hello")
181 bm := binManifest{
182 Owner: "owner",
183 Name: "gh-hello",
184 Host: "github.com",
185 Tag: "v1.0.0",
186 }
187 assert.NoError(t, stubBinaryExtension(extPath, bm))
188
189 m := newTestManager(dataDir, updateDir, nil, nil, nil)
190
191 stdout := &bytes.Buffer{}
192 stderr := &bytes.Buffer{}
193 found, err := m.Dispatch([]string{"hello", "one", "two"}, nil, stdout, stderr)
194 assert.NoError(t, err)
195 assert.True(t, found)
196
197 assert.Equal(t, fmt.Sprintf("[%s one two]\n", exePath), stdout.String())
198 assert.Equal(t, "", stderr.String())
199}
200
201func TestManager_Dispatch_ghExtensionEnv(t *testing.T) {
202 tests := []struct {

Callers

nothing calls this directly

Calls 6

stubBinaryExtensionFunction · 0.85
newTestManagerFunction · 0.85
JoinMethod · 0.80
EqualMethod · 0.80
DispatchMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected