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,7 +1,6 @@
package engine
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
@@ -12,14 +11,10 @@ import (
func TestSetup(t *testing.T) {
t.Parallel()
_, err := SetupCommunicationManager(nil)
if !errors.Is(err, errNilConfig) {
t.Errorf("error '%v', expected '%v'", err, errNilConfig)
}
assert.ErrorIs(t, err, errNilConfig)
_, err = SetupCommunicationManager(&base.CommunicationsConfig{})
if !errors.Is(err, communications.ErrNoRelayersEnabled) {
t.Errorf("error '%v', expected '%v'", err, communications.ErrNoRelayersEnabled)
}
assert.ErrorIs(t, err, communications.ErrNoRelayersEnabled)
m, err := SetupCommunicationManager(&base.CommunicationsConfig{
SlackConfig: base.SlackConfig{
@@ -72,9 +67,7 @@ func TestStart(t *testing.T) {
m.started = 1
err = m.Start()
if !errors.Is(err, ErrSubSystemAlreadyStarted) {
t.Errorf("error '%v', expected '%v'", err, ErrSubSystemAlreadyStarted)
}
assert.ErrorIs(t, err, ErrSubSystemAlreadyStarted)
}
func TestGetStatus(t *testing.T) {
@@ -94,9 +87,7 @@ func TestGetStatus(t *testing.T) {
m.started = 0
_, err = m.GetStatus()
if !errors.Is(err, ErrSubSystemNotStarted) {
t.Errorf("error '%v', expected '%v'", err, ErrSubSystemNotStarted)
}
assert.ErrorIs(t, err, ErrSubSystemNotStarted)
}
func TestStop(t *testing.T) {
@@ -115,14 +106,11 @@ func TestStop(t *testing.T) {
assert.NoError(t, err)
err = m.Stop()
if !errors.Is(err, ErrSubSystemNotStarted) {
t.Errorf("error '%v', expected '%v'", err, ErrSubSystemNotStarted)
}
assert.ErrorIs(t, err, ErrSubSystemNotStarted)
m = nil
err = m.Stop()
if !errors.Is(err, ErrNilSubsystem) {
t.Errorf("error '%v', expected '%v'", err, ErrNilSubsystem)
}
assert.ErrorIs(t, err, ErrNilSubsystem)
}
func TestPushEvent(t *testing.T) {