You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-09-16 09:26:22 +02:00
fix tests
This commit is contained in:
12131
cmd/cover.out
Normal file
12131
cmd/cover.out
Normal file
File diff suppressed because it is too large
Load Diff
@@ -235,7 +235,7 @@ func runDetect(ctx context.Context, config detectExecuteScanOptions, utils detec
|
||||
buildDescriptorList = []string{"package.json"}
|
||||
}
|
||||
|
||||
err := npmExecutor.InstallAllDependencies(buildDescriptorList)
|
||||
err := npmExecutor.InstallAllDependencies(buildDescriptorList, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -117,7 +117,7 @@ func (bundle *mtaBuildUtilsBundle) SetNpmRegistries(defaultNpmRegistry string) e
|
||||
func (bundle *mtaBuildUtilsBundle) InstallAllDependencies(defaultNpmRegistry string) error {
|
||||
npmExecutorOptions := npm.ExecutorOptions{DefaultNpmRegistry: defaultNpmRegistry, ExecRunner: bundle}
|
||||
npmExecutor := npm.NewExecutor(npmExecutorOptions)
|
||||
return npmExecutor.InstallAllDependencies(npmExecutor.FindPackageJSONFiles())
|
||||
return npmExecutor.InstallAllDependencies(npmExecutor.FindPackageJSONFiles(), "")
|
||||
}
|
||||
|
||||
func (bundle *mtaBuildUtilsBundle) DownloadAndCopySettingsFiles(globalSettingsFile string, projectSettingsFile string) error {
|
||||
|
@@ -88,7 +88,7 @@ func runNpmExecuteLint(npmExecutor npm.Executor, utils lintUtils, config *npmExe
|
||||
|
||||
if len(packagesWithLintScript) > 0 {
|
||||
if config.Install {
|
||||
err := npmExecutor.InstallAllDependencies(packagesWithLintScript)
|
||||
err := npmExecutor.InstallAllDependencies(packagesWithLintScript, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func runNpmExecuteLint(npmExecutor npm.Executor, utils lintUtils, config *npmExe
|
||||
}
|
||||
} else {
|
||||
if config.Install {
|
||||
err := npmExecutor.InstallAllDependencies(packageJSONFiles)
|
||||
err := npmExecutor.InstallAllDependencies(packageJSONFiles, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -144,7 +144,7 @@ func (w *whitesourceUtilsBundle) FindPackageJSONFiles(config *ws.ScanOptions) ([
|
||||
}
|
||||
|
||||
func (w *whitesourceUtilsBundle) InstallAllNPMDependencies(config *ws.ScanOptions, packageJSONFiles []string) error {
|
||||
return w.getNpmExecutor(config).InstallAllDependencies(packageJSONFiles)
|
||||
return w.getNpmExecutor(config).InstallAllDependencies(packageJSONFiles, "")
|
||||
}
|
||||
|
||||
func (w *whitesourceUtilsBundle) SetOptions(o piperhttp.ClientOptions) {
|
||||
|
@@ -38,7 +38,7 @@ var cycloneDxCliUrl = map[struct{ os, arch string }]string{
|
||||
// It supports both pnpm and other package managers (npm/yarn) with different BOM generation strategies.
|
||||
func (exec *Execute) CreateBOM(packageJSONFiles []string) error {
|
||||
log.Entry().Debug("Detecting package manager...")
|
||||
pm, err := exec.detectPackageManager()
|
||||
pm, err := exec.detectPackageManager("")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to detect package manager (looking for package.json, package-lock.json, pnpm-lock.yaml): %w", err)
|
||||
}
|
||||
|
@@ -96,7 +96,7 @@ func (n *NpmExecutorMock) RunScriptsInAllPackages(runScripts []string, runOption
|
||||
}
|
||||
|
||||
// InstallAllDependencies mock implementation
|
||||
func (n *NpmExecutorMock) InstallAllDependencies(packageJSONFiles []string) error {
|
||||
func (n *NpmExecutorMock) InstallAllDependencies(packageJSONFiles []string, pnpmVersion string) error {
|
||||
allPackages := n.FindPackageJSONFiles()
|
||||
if len(packageJSONFiles) != len(allPackages) {
|
||||
return fmt.Errorf("packageJSONFiles != n.FindPackageJSONFiles()")
|
||||
|
@@ -29,7 +29,7 @@ type Executor interface {
|
||||
FindPackageJSONFilesWithExcludes(excludeList []string) ([]string, error)
|
||||
FindPackageJSONFilesWithScript(packageJSONFiles []string, script string) ([]string, error)
|
||||
RunScriptsInAllPackages(runScripts []string, runOptions []string, scriptOptions []string, virtualFrameBuffer bool, excludeList []string, packagesList []string) error
|
||||
InstallAllDependencies(packageJSONFiles []string, string) error
|
||||
InstallAllDependencies(packageJSONFiles []string, pnpmVersion string) error
|
||||
PublishAllPackages(packageJSONFiles []string, registry, username, password string, packBeforePublish bool, buildCoordinates *[]versioning.Coordinates) error
|
||||
SetNpmRegistries() error
|
||||
CreateBOM(packageJSONFiles []string) error
|
||||
|
@@ -139,7 +139,7 @@ func TestNpm(t *testing.T) {
|
||||
Utils: &utils,
|
||||
Options: options,
|
||||
}
|
||||
err := exec.install("package.json")
|
||||
err := exec.install("package.json", "")
|
||||
|
||||
if assert.NoError(t, err) {
|
||||
if assert.Equal(t, 2, len(utils.execRunner.Calls)) {
|
||||
@@ -159,7 +159,7 @@ func TestNpm(t *testing.T) {
|
||||
Utils: &utils,
|
||||
Options: options,
|
||||
}
|
||||
err := exec.install("package.json")
|
||||
err := exec.install("package.json", "")
|
||||
|
||||
if assert.NoError(t, err) {
|
||||
if assert.Equal(t, 2, len(utils.execRunner.Calls)) {
|
||||
@@ -180,7 +180,7 @@ func TestNpm(t *testing.T) {
|
||||
Utils: &utils,
|
||||
Options: options,
|
||||
}
|
||||
err := exec.install("package.json")
|
||||
err := exec.install("package.json", "")
|
||||
|
||||
if assert.NoError(t, err) {
|
||||
if assert.Equal(t, 2, len(utils.execRunner.Calls)) {
|
||||
@@ -205,7 +205,7 @@ func TestNpm(t *testing.T) {
|
||||
Utils: &utils,
|
||||
Options: options,
|
||||
}
|
||||
err := exec.install("package.json")
|
||||
err := exec.install("package.json", "")
|
||||
|
||||
if assert.NoError(t, err) {
|
||||
fmt.Println(utils.execRunner.Calls)
|
||||
@@ -236,7 +236,7 @@ func TestNpm(t *testing.T) {
|
||||
Utils: &utils,
|
||||
Options: options,
|
||||
}
|
||||
err := exec.InstallAllDependencies([]string{"package.json", filepath.Join("src", "package.json")})
|
||||
err := exec.InstallAllDependencies([]string{"package.json", filepath.Join("src", "package.json")}, "")
|
||||
|
||||
if assert.NoError(t, err) {
|
||||
if assert.Equal(t, 4, len(utils.execRunner.Calls)) {
|
||||
|
@@ -70,7 +70,7 @@ func TestPackageManager(t *testing.T) {
|
||||
Options: ExecutorOptions{},
|
||||
}
|
||||
|
||||
pm, err := exec.detectPackageManager()
|
||||
pm, err := exec.detectPackageManager("")
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.expectedPM, pm.Name)
|
||||
@@ -105,7 +105,7 @@ func TestPackageManager(t *testing.T) {
|
||||
Options: ExecutorOptions{},
|
||||
}
|
||||
|
||||
_, err := exec.detectPackageManager()
|
||||
_, err := exec.detectPackageManager("")
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), tt.expectedError)
|
||||
})
|
||||
@@ -158,7 +158,7 @@ func TestPackageManager(t *testing.T) {
|
||||
Options: ExecutorOptions{},
|
||||
}
|
||||
|
||||
err := exec.install("package.json")
|
||||
err := exec.install("package.json", "")
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), tt.expectedError)
|
||||
|
Reference in New Issue
Block a user