MCPcopy Index your code
hub / github.com/cli/cli / TestManager_UpgradeExtension_GitExtension

Function TestManager_UpgradeExtension_GitExtension

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

Source from the content-addressed store, hash-verified

353}
354
355func TestManager_UpgradeExtension_GitExtension(t *testing.T) {
356 dataDir := t.TempDir()
357 updateDir := t.TempDir()
358 extensionDir := filepath.Join(dataDir, "extensions", "gh-remote")
359 assert.NoError(t, stubExtension(filepath.Join(dataDir, "extensions", "gh-remote", "gh-remote")))
360 ios, _, stdout, stderr := iostreams.Test()
361 gc, gcOne := &mockGitClient{}, &mockGitClient{}
362 gc.On("ForRepo", extensionDir).Return(gcOne).Times(3)
363 gcOne.On("Remotes").Return(nil, nil).Once()
364 gcOne.On("Pull", "", "").Return(nil).Once()
365
366 m := newTestManager(dataDir, updateDir, nil, gc, ios)
367 exts, err := m.list(false)
368 assert.NoError(t, err)
369 assert.Equal(t, 1, len(exts))
370 ext := exts[0]
371 ext.currentVersion = "old version"
372 ext.latestVersion = "new version"
373 err = m.upgradeExtension(ext, false)
374 assert.NoError(t, err)
375 assert.Equal(t, "", stdout.String())
376 assert.Equal(t, "", stderr.String())
377 gc.AssertExpectations(t)
378 gcOne.AssertExpectations(t)
379}
380
381func TestManager_UpgradeExtension_GitExtension_DryRun(t *testing.T) {
382 dataDir := t.TempDir()

Callers

nothing calls this directly

Calls 8

TestFunction · 0.92
stubExtensionFunction · 0.85
newTestManagerFunction · 0.85
JoinMethod · 0.80
listMethod · 0.80
EqualMethod · 0.80
upgradeExtensionMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected