(t *testing.T)
| 281 | } |
| 282 | |
| 283 | func TestManager_UpgradeExtensions_DryRun(t *testing.T) { |
| 284 | dataDir := t.TempDir() |
| 285 | updateDir := t.TempDir() |
| 286 | dirOne := filepath.Join(dataDir, "extensions", "gh-hello") |
| 287 | dirTwo := filepath.Join(dataDir, "extensions", "gh-two") |
| 288 | assert.NoError(t, stubExtension(filepath.Join(dataDir, "extensions", "gh-hello", "gh-hello"))) |
| 289 | assert.NoError(t, stubExtension(filepath.Join(dataDir, "extensions", "gh-two", "gh-two"))) |
| 290 | assert.NoError(t, stubLocalExtension(dataDir, filepath.Join(dataDir, "extensions", "gh-local", "gh-local"))) |
| 291 | ios, _, stdout, stderr := iostreams.Test() |
| 292 | gc, gcOne, gcTwo := &mockGitClient{}, &mockGitClient{}, &mockGitClient{} |
| 293 | gc.On("ForRepo", dirOne).Return(gcOne).Twice() |
| 294 | gc.On("ForRepo", dirTwo).Return(gcTwo).Twice() |
| 295 | gcOne.On("Remotes").Return(nil, nil).Once() |
| 296 | gcTwo.On("Remotes").Return(nil, nil).Once() |
| 297 | |
| 298 | m := newTestManager(dataDir, updateDir, nil, gc, ios) |
| 299 | m.EnableDryRunMode() |
| 300 | exts, err := m.list(false) |
| 301 | assert.NoError(t, err) |
| 302 | assert.Equal(t, 3, len(exts)) |
| 303 | for i := 0; i < 3; i++ { |
| 304 | exts[i].currentVersion = fmt.Sprintf("%d", i) |
| 305 | exts[i].latestVersion = fmt.Sprintf("%d", i+1) |
| 306 | } |
| 307 | err = m.upgradeExtensions(exts, false) |
| 308 | assert.NoError(t, err) |
| 309 | assert.Equal(t, heredoc.Doc( |
| 310 | ` |
| 311 | [hello]: would have upgraded from 0 to 1 |
| 312 | [local]: local extensions can not be upgraded |
| 313 | [ two]: would have upgraded from 2 to 3 |
| 314 | `, |
| 315 | ), stdout.String()) |
| 316 | assert.Equal(t, "", stderr.String()) |
| 317 | gc.AssertExpectations(t) |
| 318 | gcOne.AssertExpectations(t) |
| 319 | gcTwo.AssertExpectations(t) |
| 320 | } |
| 321 | |
| 322 | func TestManager_UpgradeExtension_LocalExtension(t *testing.T) { |
| 323 | dataDir := t.TempDir() |
nothing calls this directly
no test coverage detected