Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for file not found error message discrepancy in windows #1575

Merged
merged 2 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion test/e2e/service_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"path/filepath"
"testing"

"gotest.tools/v3/assert/cmp"

"gotest.tools/v3/assert"

"knative.dev/client/lib/test"
Expand Down Expand Up @@ -124,11 +126,20 @@ 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) {
out := r.KnTest().Kn().Run("service", "create", serviceName, "--filename", filePath)
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 {
Copy link
Contributor

@dsimansk dsimansk Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if that shouldn't be rather == windows check. Well the comment should be a few lines below. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment for clarity

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks!

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)
}
2 changes: 1 addition & 1 deletion test/e2e/service_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}