mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
fix(push): fix tests
This commit is contained in:
@ -89,10 +89,14 @@ type ProcessorError struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *ProcessorError) Error() string {
|
func (e *ProcessorError) Error() string {
|
||||||
if e.Err != nil {
|
notifInfo := ""
|
||||||
return fmt.Sprintf("%s %s failed for '%s': %s (%v)", e.ProcessorType, e.Operation, e.PushNotificationName, e.Reason, e.Err)
|
if e.PushNotificationName != "" {
|
||||||
|
notifInfo = fmt.Sprintf(" for '%s'", e.PushNotificationName)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s %s failed for '%s': %s", e.ProcessorType, e.Operation, e.PushNotificationName, e.Reason)
|
if e.Err != nil {
|
||||||
|
return fmt.Sprintf("%s %s failed%s: %s (%v)", e.ProcessorType, e.Operation, notifInfo, e.Reason, e.Err)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s %s failed%s: %s", e.ProcessorType, e.Operation, notifInfo, e.Reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ProcessorError) Unwrap() error {
|
func (e *ProcessorError) Unwrap() error {
|
||||||
|
@ -32,12 +32,12 @@ func NewTestHandler(name string) *TestHandler {
|
|||||||
type MockNetConn struct{}
|
type MockNetConn struct{}
|
||||||
|
|
||||||
func (m *MockNetConn) Read(b []byte) (n int, err error) { return 0, nil }
|
func (m *MockNetConn) Read(b []byte) (n int, err error) { return 0, nil }
|
||||||
func (m *MockNetConn) Write(b []byte) (n int, err error) { return len(b), nil }
|
func (m *MockNetConn) Write(b []byte) (n int, err error) { return len(b), nil }
|
||||||
func (m *MockNetConn) Close() error { return nil }
|
func (m *MockNetConn) Close() error { return nil }
|
||||||
func (m *MockNetConn) LocalAddr() net.Addr { return nil }
|
func (m *MockNetConn) LocalAddr() net.Addr { return nil }
|
||||||
func (m *MockNetConn) RemoteAddr() net.Addr { return nil }
|
func (m *MockNetConn) RemoteAddr() net.Addr { return nil }
|
||||||
func (m *MockNetConn) SetDeadline(t time.Time) error { return nil }
|
func (m *MockNetConn) SetDeadline(t time.Time) error { return nil }
|
||||||
func (m *MockNetConn) SetReadDeadline(t time.Time) error { return nil }
|
func (m *MockNetConn) SetReadDeadline(t time.Time) error { return nil }
|
||||||
func (m *MockNetConn) SetWriteDeadline(t time.Time) error { return nil }
|
func (m *MockNetConn) SetWriteDeadline(t time.Time) error { return nil }
|
||||||
|
|
||||||
func (h *TestHandler) HandlePushNotification(ctx context.Context, handlerCtx NotificationHandlerContext, notification []interface{}) error {
|
func (h *TestHandler) HandlePushNotification(ctx context.Context, handlerCtx NotificationHandlerContext, notification []interface{}) error {
|
||||||
@ -1564,7 +1564,7 @@ func TestHandlerError(t *testing.T) {
|
|||||||
// TestProcessorError tests the ProcessorError structured error type
|
// TestProcessorError tests the ProcessorError structured error type
|
||||||
func TestProcessorError(t *testing.T) {
|
func TestProcessorError(t *testing.T) {
|
||||||
t.Run("ProcessorErrorWithoutWrappedError", func(t *testing.T) {
|
t.Run("ProcessorErrorWithoutWrappedError", func(t *testing.T) {
|
||||||
err := NewProcessorError("processor", "process", "invalid notification format", nil)
|
err := NewProcessorError("processor", "process", "", "invalid notification format", nil)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("NewProcessorError should not return nil")
|
t.Error("NewProcessorError should not return nil")
|
||||||
@ -1594,7 +1594,7 @@ func TestProcessorError(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("ProcessorErrorWithWrappedError", func(t *testing.T) {
|
t.Run("ProcessorErrorWithWrappedError", func(t *testing.T) {
|
||||||
wrappedErr := errors.New("network error")
|
wrappedErr := errors.New("network error")
|
||||||
err := NewProcessorError("void_processor", "register", "disabled", wrappedErr)
|
err := NewProcessorError("void_processor", "register", "", "disabled", wrappedErr)
|
||||||
|
|
||||||
expectedMsg := "void_processor register failed: disabled (network error)"
|
expectedMsg := "void_processor register failed: disabled (network error)"
|
||||||
if err.Error() != expectedMsg {
|
if err.Error() != expectedMsg {
|
||||||
|
Reference in New Issue
Block a user