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