(t *testing.T)
| 357 | } |
| 358 | |
| 359 | func TestManager_UpgradeExtensions_DryRun(t *testing.T) { |
| 360 | dataDir := t.TempDir() |
| 361 | updateDir := t.TempDir() |
| 362 | dirOne := filepath.Join(dataDir, "extensions", "gh-hello") |
| 363 | dirTwo := filepath.Join(dataDir, "extensions", "gh-two") |
| 364 | assert.NoError(t, stubExtension(filepath.Join(dataDir, "extensions", "gh-hello", "gh-hello"))) |
| 365 | assert.NoError(t, stubExtension(filepath.Join(dataDir, "extensions", "gh-two", "gh-two"))) |
| 366 | assert.NoError(t, stubLocalExtension(dataDir, filepath.Join(dataDir, "extensions", "gh-local", "gh-local"))) |
| 367 | ios, _, stdout, stderr := iostreams.Test() |
| 368 | gc, gcOne, gcTwo := &mockGitClient{}, &mockGitClient{}, &mockGitClient{} |
| 369 | gc.On("ForRepo", dirOne).Return(gcOne).Twice() |
| 370 | gc.On("ForRepo", dirTwo).Return(gcTwo).Twice() |
| 371 | gcOne.On("Remotes").Return(nil, nil).Once() |
| 372 | gcTwo.On("Remotes").Return(nil, nil).Once() |
| 373 | |
| 374 | m := newTestManager(dataDir, updateDir, nil, gc, ios) |
| 375 | m.EnableDryRunMode() |
| 376 | exts, err := m.list(false) |
| 377 | assert.NoError(t, err) |
| 378 | assert.Equal(t, 3, len(exts)) |
| 379 | for i := 0; i < 3; i++ { |
| 380 | exts[i].currentVersion = fmt.Sprintf("%d", i) |
| 381 | exts[i].latestVersion = fmt.Sprintf("%d", i+1) |
| 382 | } |
| 383 | err = m.upgradeExtensions(exts, false) |
| 384 | assert.NoError(t, err) |
| 385 | assert.Equal(t, heredoc.Doc( |
| 386 | ` |
| 387 | [hello]: would have upgraded from 0 to 1 |
| 388 | [local]: local extensions can not be upgraded |
| 389 | [ two]: would have upgraded from 2 to 3 |
| 390 | `, |
| 391 | ), stdout.String()) |
| 392 | assert.Equal(t, "", stderr.String()) |
| 393 | gc.AssertExpectations(t) |
| 394 | gcOne.AssertExpectations(t) |
| 395 | gcTwo.AssertExpectations(t) |
| 396 | } |
| 397 | |
| 398 | func TestManager_UpgradeExtension_LocalExtension(t *testing.T) { |
| 399 | dataDir := t.TempDir() |
nothing calls this directly
no test coverage detected