MCPcopy
hub / github.com/cli/cli / TestManager_Create

Function TestManager_Create

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

Source from the content-addressed store, hash-verified

1284}
1285
1286func TestManager_Create(t *testing.T) {
1287 tempDir := t.TempDir()
1288 t.Chdir(tempDir)
1289 err := os.MkdirAll("gh-test", 0755)
1290 require.NoError(t, err)
1291
1292 ios, _, stdout, stderr := iostreams.Test()
1293
1294 gc, gcOne := &mockGitClient{}, &mockGitClient{}
1295 gc.On("ForRepo", "gh-test").Return(gcOne).Once()
1296 gc.On("CommandOutput", []string{"init", "--quiet", "gh-test"}).Return("", nil).Once()
1297 gcOne.On("CommandOutput", []string{"add", "gh-test", "--chmod=+x"}).Return("", nil).Once()
1298 gcOne.On("CommandOutput", []string{"commit", "-m", "initial commit"}).Return("", nil).Once()
1299
1300 updateDir := t.TempDir()
1301 m := newTestManager(".", updateDir, nil, gc, ios)
1302
1303 err = m.Create("gh-test", extensions.GitTemplateType)
1304 assert.NoError(t, err)
1305 files, err := os.ReadDir("gh-test")
1306 assert.NoError(t, err)
1307 assert.Equal(t, []string{"gh-test"}, fileNames(files))
1308
1309 assert.Equal(t, "", stdout.String())
1310 assert.Equal(t, "", stderr.String())
1311 gc.AssertExpectations(t)
1312 gcOne.AssertExpectations(t)
1313}
1314
1315func TestManager_Create_go_binary(t *testing.T) {
1316 tempDir := t.TempDir()

Callers

nothing calls this directly

Calls 6

TestFunction · 0.92
newTestManagerFunction · 0.85
fileNamesFunction · 0.85
EqualMethod · 0.80
CreateMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected