| 1364 | } |
| 1365 | |
| 1366 | func TestManager_Create_other_binary(t *testing.T) { |
| 1367 | tempDir := t.TempDir() |
| 1368 | t.Chdir(tempDir) |
| 1369 | err := os.MkdirAll("gh-test", 0755) |
| 1370 | require.NoError(t, err) |
| 1371 | |
| 1372 | ios, _, stdout, stderr := iostreams.Test() |
| 1373 | |
| 1374 | gc, gcOne := &mockGitClient{}, &mockGitClient{} |
| 1375 | gc.On("ForRepo", "gh-test").Return(gcOne).Once() |
| 1376 | gc.On("CommandOutput", []string{"init", "--quiet", "gh-test"}).Return("", nil).Once() |
| 1377 | gcOne.On("CommandOutput", []string{"add", filepath.Join("script", "build.sh"), "--chmod=+x"}).Return("", nil).Once() |
| 1378 | gcOne.On("CommandOutput", []string{"add", "."}).Return("", nil).Once() |
| 1379 | gcOne.On("CommandOutput", []string{"commit", "-m", "initial commit"}).Return("", nil).Once() |
| 1380 | |
| 1381 | updateDir := t.TempDir() |
| 1382 | m := newTestManager(".", updateDir, nil, gc, ios) |
| 1383 | |
| 1384 | err = m.Create("gh-test", extensions.OtherBinTemplateType) |
| 1385 | assert.NoError(t, err) |
| 1386 | |
| 1387 | files, err := os.ReadDir("gh-test") |
| 1388 | assert.NoError(t, err) |
| 1389 | assert.Equal(t, 2, len(files)) |
| 1390 | |
| 1391 | files, err = os.ReadDir(filepath.Join("gh-test", ".github", "workflows")) |
| 1392 | assert.NoError(t, err) |
| 1393 | assert.Equal(t, []string{"release.yml"}, fileNames(files)) |
| 1394 | |
| 1395 | files, err = os.ReadDir(filepath.Join("gh-test", "script")) |
| 1396 | assert.NoError(t, err) |
| 1397 | assert.Equal(t, []string{"build.sh"}, fileNames(files)) |
| 1398 | |
| 1399 | assert.Equal(t, "", stdout.String()) |
| 1400 | assert.Equal(t, "", stderr.String()) |
| 1401 | gc.AssertExpectations(t) |
| 1402 | gcOne.AssertExpectations(t) |
| 1403 | } |
| 1404 | |
| 1405 | func Test_ensurePrefixed(t *testing.T) { |
| 1406 | tests := []struct { |