mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-09 15:15:08 +02:00
Remove testutils.Check(t, err) and replace it with require.NoError which gives a clearer error message and a full stacktrace
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/ddworken/hishtory/shared/testutils"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type operation struct {
|
||||
@ -79,11 +80,11 @@ func fuzzTest(t *testing.T, tester shellTester, input string) {
|
||||
switchToDevice(&devices, op.device)
|
||||
if op.cmd != "" {
|
||||
_, err := tester.RunInteractiveShellRelaxed(t, op.cmd)
|
||||
testutils.Check(t, err)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
if op.redactQuery != "" {
|
||||
_, err := tester.RunInteractiveShellRelaxed(t, `HISHTORY_REDACT_FORCE=1 hishtory redact `+op.redactQuery)
|
||||
testutils.Check(t, err)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// Calculate the expected output of hishtory export
|
||||
@ -111,7 +112,7 @@ func fuzzTest(t *testing.T, tester shellTester, input string) {
|
||||
|
||||
// Run hishtory export and check the output
|
||||
out, err := tester.RunInteractiveShellRelaxed(t, `hishtory export -export -pipefail`)
|
||||
testutils.Check(t, err)
|
||||
require.NoError(t, err)
|
||||
expectedOutput := keyToCommands[op.device.key]
|
||||
if diff := cmp.Diff(expectedOutput, out); diff != "" {
|
||||
t.Fatalf("hishtory export mismatch for input=%#v key=%s (-expected +got):\n%s\nout=%#v", input, op.device.key, diff, out)
|
||||
@ -122,7 +123,7 @@ func fuzzTest(t *testing.T, tester shellTester, input string) {
|
||||
for _, op := range ops {
|
||||
switchToDevice(&devices, op.device)
|
||||
out, err := tester.RunInteractiveShellRelaxed(t, `hishtory export -export -pipefail`)
|
||||
testutils.Check(t, err)
|
||||
require.NoError(t, err)
|
||||
expectedOutput := keyToCommands[op.device.key]
|
||||
if diff := cmp.Diff(expectedOutput, out); diff != "" {
|
||||
t.Fatalf("hishtory export mismatch for key=%s (-expected +got):\n%s\nout=%#v", op.device.key, diff, out)
|
||||
|
Reference in New Issue
Block a user