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

Function TestManager_Dispatch

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

Source from the content-addressed store, hash-verified

145}
146
147func TestManager_Dispatch(t *testing.T) {
148 dataDir := t.TempDir()
149 updateDir := t.TempDir()
150 extDir := filepath.Join(dataDir, "extensions", "gh-hello")
151 extPath := filepath.Join(dataDir, "extensions", "gh-hello", "gh-hello")
152 assert.NoError(t, stubExtension(extPath))
153
154 gc, gcOne := &mockGitClient{}, &mockGitClient{}
155 gc.On("ForRepo", extDir).Return(gcOne).Once()
156
157 m := newTestManager(dataDir, updateDir, nil, gc, nil)
158
159 stdout := &bytes.Buffer{}
160 stderr := &bytes.Buffer{}
161 found, err := m.Dispatch([]string{"hello", "one", "two"}, nil, stdout, stderr)
162 assert.NoError(t, err)
163 assert.True(t, found)
164
165 if runtime.GOOS == "windows" {
166 assert.Equal(t, fmt.Sprintf("[sh -c command \"$@\" -- %s one two]\n", extPath), stdout.String())
167 } else {
168 assert.Equal(t, fmt.Sprintf("[%s one two]\n", extPath), stdout.String())
169 }
170 assert.Equal(t, "", stderr.String())
171
172 gc.AssertExpectations(t)
173 gcOne.AssertExpectations(t)
174}
175
176func TestManager_Dispatch_binary(t *testing.T) {
177 dataDir := t.TempDir()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected