You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +02:00 
			
		
		
		
	fix windows specific test failures (#3155)
- gaugeExecuteTests - newmanExecute Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
This commit is contained in:
		| @@ -90,7 +90,7 @@ func installGauge(gaugeInstallCommand string, utils gaugeExecuteTestsUtils) erro | ||||
|  | ||||
| func installLanguageRunner(languageRunner string, utils gaugeExecuteTestsUtils) error { | ||||
| 	installParams := []string{"install", languageRunner} | ||||
| 	gaugePath := filepath.Join(utils.Getenv("HOME"), filepath.FromSlash("/.npm-global/bin/gauge")) | ||||
| 	gaugePath := filepath.FromSlash(filepath.Join(utils.Getenv("HOME"), "/.npm-global/bin/gauge")) | ||||
| 	err := utils.RunExecutable(gaugePath, installParams...) | ||||
| 	if err != nil { | ||||
| 		log.SetErrorCategory(log.ErrorConfiguration) | ||||
| @@ -105,7 +105,7 @@ func runGauge(config *gaugeExecuteTestsOptions, utils gaugeExecuteTestsUtils) er | ||||
| 	if config.TestOptions != "" { | ||||
| 		runCommandTokens = append(runCommandTokens, strings.Split(config.TestOptions, " ")...) | ||||
| 	} | ||||
| 	gaugePath := filepath.Join(utils.Getenv("HOME"), filepath.FromSlash("/.npm-global/bin/gauge")) | ||||
| 	gaugePath := filepath.FromSlash(filepath.Join(utils.Getenv("HOME"), "/.npm-global/bin/gauge")) | ||||
| 	err := utils.RunExecutable(gaugePath, runCommandTokens...) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrap(ErrorGaugeRun, err.Error()) | ||||
|   | ||||
| @@ -16,7 +16,7 @@ type gaugeExecuteTestsMockUtils struct { | ||||
|  | ||||
| func (utils gaugeExecuteTestsMockUtils) Getenv(key string) string { | ||||
| 	if key == "HOME" { | ||||
| 		return "/home/node" | ||||
| 		return filepath.FromSlash("/home/node") | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
| @@ -30,7 +30,7 @@ func TestRunGaugeExecuteTests(t *testing.T) { | ||||
| 		RunCommand:     "run", | ||||
| 		TestOptions:    "specs", | ||||
| 	} | ||||
| 	gaugeBin := "home/node/.npm-global/bin/gauge" | ||||
| 	gaugeBinRegEx := "home.node..npm-global.bin.gauge" | ||||
|  | ||||
| 	t.Run("success case", func(t *testing.T) { | ||||
| 		t.Parallel() | ||||
| @@ -76,7 +76,7 @@ func TestRunGaugeExecuteTests(t *testing.T) { | ||||
| 		badInstallConfig.LanguageRunner = "wrong" | ||||
|  | ||||
| 		mockUtils := gaugeExecuteTestsMockUtils{ | ||||
| 			ExecMockRunner: &mock.ExecMockRunner{ShouldFailOnCommand: map[string]error{gaugeBin + " install wrong": errors.New("error installing runner")}}, | ||||
| 			ExecMockRunner: &mock.ExecMockRunner{ShouldFailOnCommand: map[string]error{gaugeBinRegEx + " install wrong": errors.New("error installing runner")}}, | ||||
| 			FilesMock:      &mock.FilesMock{}, | ||||
| 		} | ||||
|  | ||||
| @@ -94,7 +94,7 @@ func TestRunGaugeExecuteTests(t *testing.T) { | ||||
| 		t.Parallel() | ||||
|  | ||||
| 		mockUtils := gaugeExecuteTestsMockUtils{ | ||||
| 			ExecMockRunner: &mock.ExecMockRunner{ShouldFailOnCommand: map[string]error{gaugeBin + " run specs": errors.New("error running gauge")}}, | ||||
| 			ExecMockRunner: &mock.ExecMockRunner{ShouldFailOnCommand: map[string]error{gaugeBinRegEx + " run specs": errors.New("error running gauge")}}, | ||||
| 			FilesMock:      &mock.FilesMock{}, | ||||
| 		} | ||||
|  | ||||
|   | ||||
| @@ -60,8 +60,8 @@ func TestRunNewmanExecute(t *testing.T) { | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "node", params: []string{"--version"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "npm", params: []string{"--version"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "npm", params: []string{"install", "newman", "--global", "--quiet", "--prefix=~/.npm-global"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "/home/node/.npm-global/bin/newman", params: []string{"run", "localFile.json", "--environment", "env.json", "--globals", "globals.json", "--reporters", "junit,html", "--reporter-junit-export", "target/newman/TEST-localFile.xml", "--reporter-html-export", "target/newman/TEST-localFile.html", "--suppress-exit-code"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "/home/node/.npm-global/bin/newman", params: []string{"run", "localFile2.json", "--environment", "env.json", "--globals", "globals.json", "--reporters", "junit,html", "--reporter-junit-export", "target/newman/TEST-localFile2.xml", "--reporter-html-export", "target/newman/TEST-localFile2.html", "--suppress-exit-code"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: filepath.FromSlash("/home/node/.npm-global/bin/newman"), params: []string{"run", "localFile.json", "--environment", "env.json", "--globals", "globals.json", "--reporters", "junit,html", "--reporter-junit-export", "target/newman/TEST-localFile.xml", "--reporter-html-export", "target/newman/TEST-localFile.html", "--suppress-exit-code"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: filepath.FromSlash("/home/node/.npm-global/bin/newman"), params: []string{"run", "localFile2.json", "--environment", "env.json", "--globals", "globals.json", "--reporters", "junit,html", "--reporter-junit-export", "target/newman/TEST-localFile2.xml", "--reporter-html-export", "target/newman/TEST-localFile2.html", "--suppress-exit-code"}}) | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("happy path with fail on error", func(t *testing.T) { | ||||
| @@ -80,8 +80,8 @@ func TestRunNewmanExecute(t *testing.T) { | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "node", params: []string{"--version"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "npm", params: []string{"--version"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "npm", params: []string{"install", "newman", "--global", "--quiet", "--prefix=~/.npm-global"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "/home/node/.npm-global/bin/newman", params: []string{"run", "localFile.json", "--environment", "env.json", "--globals", "globals.json", "--reporters", "junit,html", "--reporter-junit-export", "target/newman/TEST-localFile.xml", "--reporter-html-export", "target/newman/TEST-localFile.html"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: "/home/node/.npm-global/bin/newman", params: []string{"run", "localFile2.json", "--environment", "env.json", "--globals", "globals.json", "--reporters", "junit,html", "--reporter-junit-export", "target/newman/TEST-localFile2.xml", "--reporter-html-export", "target/newman/TEST-localFile2.html"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: filepath.FromSlash("/home/node/.npm-global/bin/newman"), params: []string{"run", "localFile.json", "--environment", "env.json", "--globals", "globals.json", "--reporters", "junit,html", "--reporter-junit-export", "target/newman/TEST-localFile.xml", "--reporter-html-export", "target/newman/TEST-localFile.html"}}) | ||||
| 		assert.Contains(t, utils.executedExecutables, executedExecutables{executable: filepath.FromSlash("/home/node/.npm-global/bin/newman"), params: []string{"run", "localFile2.json", "--environment", "env.json", "--globals", "globals.json", "--reporters", "junit,html", "--reporter-junit-export", "target/newman/TEST-localFile2.xml", "--reporter-html-export", "target/newman/TEST-localFile2.html"}}) | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("error on newman execution", func(t *testing.T) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user