sq/libsq/core/errz/internal_test.go
Neil O'Toole db55986980
#307: Ingest cache (#354)
- Support for ingest cache, download cache, and progress bars.
2024-01-14 18:45:34 -07:00

41 lines
787 B
Go

package errz
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
//nolint:errorlint
func TestAlienCause(t *testing.T) {
err := New("boo")
cause := err.(*errz).alienCause()
require.Nil(t, cause)
err = Err(context.DeadlineExceeded)
cause = err.(*errz).alienCause()
require.Equal(t, context.DeadlineExceeded, cause)
err = Err(context.DeadlineExceeded)
err = Wrap(err, "wrap")
cause = err.(*errz).alienCause()
require.Equal(t, context.DeadlineExceeded, cause)
}
//nolint:errorlint
func TestAppendNilToMulti(t *testing.T) {
merr := Append(New("a"), New("b"))
_, ok := merr.(*multiErr)
require.True(t, ok)
got := Append(merr, nil)
_, ok = got.(*multiErr)
require.True(t, ok)
got = Append(nil, merr)
_, ok = got.(*multiErr)
require.True(t, ok)
}