| 1440 | } |
| 1441 | |
| 1442 | func TestManager_Create_other_binary(t *testing.T) { |
| 1443 | tempDir := t.TempDir() |
| 1444 | t.Chdir(tempDir) |
| 1445 | err := os.MkdirAll("gh-test", 0755) |
| 1446 | require.NoError(t, err) |
| 1447 | |
| 1448 | ios, _, stdout, stderr := iostreams.Test() |
| 1449 | |
| 1450 | gc, gcOne := &mockGitClient{}, &mockGitClient{} |
| 1451 | gc.On("ForRepo", "gh-test").Return(gcOne).Once() |
| 1452 | gc.On("CommandOutput", []string{"init", "--quiet", "gh-test"}).Return("", nil).Once() |
| 1453 | gcOne.On("CommandOutput", []string{"add", filepath.Join("script", "build.sh"), "--chmod=+x"}).Return("", nil).Once() |
| 1454 | gcOne.On("CommandOutput", []string{"add", "."}).Return("", nil).Once() |
| 1455 | gcOne.On("CommandOutput", []string{"commit", "-m", "initial commit"}).Return("", nil).Once() |
| 1456 | |
| 1457 | updateDir := t.TempDir() |
| 1458 | m := newTestManager(".", updateDir, nil, gc, ios) |
| 1459 | |
| 1460 | err = m.Create("gh-test", extensions.OtherBinTemplateType) |
| 1461 | assert.NoError(t, err) |
| 1462 | |
| 1463 | files, err := os.ReadDir("gh-test") |
| 1464 | assert.NoError(t, err) |
| 1465 | assert.Equal(t, 2, len(files)) |
| 1466 | |
| 1467 | files, err = os.ReadDir(filepath.Join("gh-test", ".github", "workflows")) |
| 1468 | assert.NoError(t, err) |
| 1469 | assert.Equal(t, []string{"release.yml"}, fileNames(files)) |
| 1470 | |
| 1471 | files, err = os.ReadDir(filepath.Join("gh-test", "script")) |
| 1472 | assert.NoError(t, err) |
| 1473 | assert.Equal(t, []string{"build.sh"}, fileNames(files)) |
| 1474 | |
| 1475 | assert.Equal(t, "", stdout.String()) |
| 1476 | assert.Equal(t, "", stderr.String()) |
| 1477 | gc.AssertExpectations(t) |
| 1478 | gcOne.AssertExpectations(t) |
| 1479 | } |
| 1480 | |
| 1481 | func Test_ensurePrefixed(t *testing.T) { |
| 1482 | tests := []struct { |