codebase: Replace !errors.Is(err, target) with testify (#1931)

* tests: Replace !errors.Is(err, target) with testify equivalents

* codebase: Manual !errors.Is(err, target) replacements

* typo: Replace errMisMatchedEvent with errMismatchedEvent

* tests: Enhance error messages for better output

* tests: Refactor error assertions in various test cases to use require and improve clarity

* misc linter: Fix assert should wording

* tests: Simplify assertions in TestCreateSignals for clarity and conciseness

* tests: Enhance assertion message in TestCreateSignals
This commit is contained in:
Adrian Gallagher
2025-06-10 16:29:57 +10:00
committed by GitHub
parent 122ab2f849
commit 19b8957f3f
109 changed files with 2485 additions and 5670 deletions

View File

@@ -1,23 +1,19 @@
package gct
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
"github.com/thrasher-corp/gocryptotrader/common"
)
func TestErrorResponse(t *testing.T) {
t.Parallel()
_, err := errorResponsef("")
if !errors.Is(err, errFormatStringIsEmpty) {
t.Fatalf("received: '%v' but expected: '%v'", err, errFormatStringIsEmpty)
}
require.ErrorIs(t, err, errFormatStringIsEmpty)
_, err = errorResponsef("--")
if !errors.Is(err, errNoArguments) {
t.Fatalf("received: '%v' but expected: '%v'", err, errNoArguments)
}
require.ErrorIs(t, err, errNoArguments)
errResp, err := errorResponsef("error %s", "hello")
if err != nil {
@@ -32,7 +28,5 @@ func TestErrorResponse(t *testing.T) {
func TestConstructRuntimeError(t *testing.T) {
t.Parallel()
err := constructRuntimeError(0, "", "", nil)
if !errors.Is(err, common.ErrTypeAssertFailure) {
t.Fatalf("received: '%v' but expected: '%v'", err, common.ErrTypeAssertFailure)
}
require.ErrorIs(t, err, common.ErrTypeAssertFailure)
}