u5surf commented on issue #3813:
URL: https://github.com/apache/camel-k/issues/3813#issuecomment-1328157135
@squakez
Hi, I changed the test cases what you said, but It seems to be failed.
```
diff --git a/pkg/util/command_test.go b/pkg/util/command_test.go
index 98187b097..d68a2e774 100644
--- a/pkg/util/command_test.go
+++ b/pkg/util/command_test.go
@@ -52,9 +52,9 @@ func TestRunAndLog(t *testing.T) {
}
func TestRunAndLogInvalid(t *testing.T) {
- cmd := exec.CommandContext(context.Background(), "date", "-dsa")
+ cmd := exec.CommandContext(context.Background(), "go", "help", "dsa")
err := RunAndLog(context.Background(), cmd, loggerInfo, loggerError)
assert.NotNil(t, err)
- assert.ErrorContains(t, err, "exit status 1")
+ assert.Equal(t, "go help dsa: unknown help topic. Run 'go help'.:
exit status 2", err.Error())
}
```
If we check only phrase of the `: exit status 2`, we can check by
assert.ErrorContains, but
I'm confusing that it doen't satisfy what you said that "we're not testing
what we expect to test as we need to check an additional message beside the
exit status 1."
```
--- FAIL: TestRunAndLogInvalid (0.00s)
command_test.go:59:
Error Trace:
/home/u5surf/camel-k/pkg/util/command_test.go:59
Error: Not equal:
expected: "go help dsa: unknown help topic.
Run 'go help'.: exit status 2"
actual : ": exit status 2"
Diff:
--- Expected
+++ Actual
@@ -1 +1 @@
-go help dsa: unknown help topic. Run 'go
help'.: exit status 2
+: exit status 2
Test: TestRunAndLogInvalid
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]