mirror of https://github.com/knative/client.git
Fix for file not found error message discrepancy in windows (#1575)
* Fix for file not found error message discrepancy in windows * Added comment
This commit is contained in:
parent
29fff9af50
commit
ddbae2e96e
|
|
@ -24,6 +24,8 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"gotest.tools/v3/assert/cmp"
|
||||||
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
|
|
||||||
"knative.dev/client/lib/test"
|
"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) {
|
func serviceCreateFromFileError(r *test.KnRunResultCollector, serviceName, filePath string) {
|
||||||
out := r.KnTest().Kn().Run("service", "create", serviceName, "--filename", filePath)
|
out := r.KnTest().Kn().Run("service", "create", serviceName, "--filename", filePath)
|
||||||
r.AssertError(out)
|
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) {
|
func serviceCreateFromFileNameMismatch(r *test.KnRunResultCollector, serviceName, filePath string) {
|
||||||
|
|
@ -132,3 +134,12 @@ func serviceCreateFromFileNameMismatch(r *test.KnRunResultCollector, serviceName
|
||||||
r.AssertError(out)
|
r.AssertError(out)
|
||||||
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stderr, "provided", "'"+serviceName+"'", "name", "match", "from", "file"))
|
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)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,5 +90,5 @@ func serviceImportExistsError(r *test.KnRunResultCollector, filename string) {
|
||||||
func serviceImportFileError(r *test.KnRunResultCollector, filePath string) {
|
func serviceImportFileError(r *test.KnRunResultCollector, filePath string) {
|
||||||
out := r.KnTest().Kn().Run("service", "import", filePath)
|
out := r.KnTest().Kn().Run("service", "import", filePath)
|
||||||
r.AssertError(out)
|
r.AssertError(out)
|
||||||
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stderr, "no", "such", "file", "directory", filePath))
|
assert.Check(r.T(), fileNotFoundErrorCheck(out, filePath))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue