Преглед изворни кода

Merge pull request #226 from eargollo/windows-test

Adapt test message to run tests in Windows
Zachary Rice пре 6 година
родитељ
комит
474266c0b5
1 измењених фајлова са 11 додато и 2 уклоњено
  1. 11 2
      src/gitleaks_test.go

+ 11 - 2
src/gitleaks_test.go

@@ -6,6 +6,7 @@ import (
 	"os"
 	"path"
 	"regexp"
+	"runtime"
 	"strings"
 	"testing"
 	"time"
@@ -182,7 +183,7 @@ func TestRun(t *testing.T) {
 			},
 			description:    "test leak",
 			numLeaks:       0,
-			expectedErrMsg: "unable to generate ssh key: open trash: no such file or directory",
+			expectedErrMsg: fmt.Sprintf("unable to generate ssh key: open trash: %s", noSuchFileMessage()),
 		},
 		{
 			testOpts: &Options{
@@ -749,7 +750,7 @@ func TestLoadToml(t *testing.T) {
 			testOpts:       &Options{},
 			description:    "env var path to no config",
 			configPath:     noConfigPath,
-			expectedErrMsg: fmt.Sprintf("problem loading config: open %s: no such file or directory", noConfigPath),
+			expectedErrMsg: fmt.Sprintf("problem loading config: open %s: %s", noConfigPath, noSuchFileMessage()),
 		},
 	}
 
@@ -773,3 +774,11 @@ func TestLoadToml(t *testing.T) {
 		})
 	}
 }
+
+func noSuchFileMessage() string {
+	if runtime.GOOS == "windows" {
+		// Adapt to Windws
+		return "The system cannot find the file specified."
+	}
+	return "no such file or directory"
+}