mirror of
https://github.com/foomo/gotsrpc.git
synced 2026-08-12 21:00:23 +00:00
32 lines
630 B
Go
32 lines
630 B
Go
package gotsrpc //nolint:testpackage
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestClientError(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
t.Run("wraps and unwraps the underlying error", func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
inner := errors.New("boom")
|
|
ce := NewClientError(inner)
|
|
require.NotNil(t, ce)
|
|
assert.Equal(t, "boom", ce.Error())
|
|
assert.Same(t, inner, ce.Unwrap())
|
|
assert.ErrorIs(t, ce, inner)
|
|
})
|
|
|
|
t.Run("unwrap returns nil when no inner error", func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
ce := &ClientError{}
|
|
assert.NoError(t, ce.Unwrap())
|
|
})
|
|
}
|