diff --git a/test/e2e/service_file_test.go b/test/e2e/service_file_test.go index 2b30717fa2..67de276174 100644 --- a/test/e2e/service_file_test.go +++ b/test/e2e/service_file_test.go @@ -24,6 +24,8 @@ import ( "path/filepath" "testing" + "gotest.tools/v3/assert/cmp" + "gotest.tools/v3/assert" "knative.dev/client/lib/test" @@ -124,7 +126,7 @@ func serviceCreateFromFile(r *test.KnRunResultCollector, serviceName, filePath s func serviceCreateFromFileError(r *test.KnRunResultCollector, serviceName, filePath string) { out := r.KnTest().Kn().Run("service", "create", serviceName, "--filename", filePath) r.AssertError(out) - assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stderr, "no", "such", "file", "directory", filePath)) + assert.Check(r.T(), fileNotFoundErrorCheck(out, filePath)) } func serviceCreateFromFileNameMismatch(r *test.KnRunResultCollector, serviceName, filePath string) { @@ -132,3 +134,12 @@ func serviceCreateFromFileNameMismatch(r *test.KnRunResultCollector, serviceName r.AssertError(out) assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stderr, "provided", "'"+serviceName+"'", "name", "match", "from", "file")) } + +func fileNotFoundErrorCheck(out test.KnRunResult, filePath string) cmp.Comparison { + result := util.ContainsAllIgnoreCase(out.Stderr, "no", "such", "file", "directory", filePath) + if result() == cmp.ResultSuccess { + return result + } + // Check for Windows specific error message in case file is not found + return util.ContainsAllIgnoreCase(out.Stderr, "system", "cannot", "find", "file", "specified", filePath) +} diff --git a/test/e2e/service_import_test.go b/test/e2e/service_import_test.go index 5f37f805d0..536c4ccfb3 100644 --- a/test/e2e/service_import_test.go +++ b/test/e2e/service_import_test.go @@ -90,5 +90,5 @@ func serviceImportExistsError(r *test.KnRunResultCollector, filename string) { func serviceImportFileError(r *test.KnRunResultCollector, filePath string) { out := r.KnTest().Kn().Run("service", "import", filePath) r.AssertError(out) - assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stderr, "no", "such", "file", "directory", filePath)) + assert.Check(r.T(), fileNotFoundErrorCheck(out, filePath)) }