Revision 0a607ab97d6818295b573f2612478be936e847a6 authored by renovate[bot] on 08 June 2023, 15:08:37 UTC, committed by GitHub on 08 June 2023, 15:08:37 UTC
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 093d0a4
nodes_test.go
package expr
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
type expectedError struct{}
func (e expectedError) Error() string {
return "expected"
}
func TestQueryError_Error(t *testing.T) {
e := QueryError{
RefID: "A",
Err: errors.New("this is an error message"),
}
assert.EqualError(t, e, "failed to execute query A: this is an error message")
}
func TestQueryError_Unwrap(t *testing.T) {
t.Run("errors.Is", func(t *testing.T) {
expectedIsErr := errors.New("expected")
e := QueryError{
RefID: "A",
Err: expectedIsErr,
}
assert.True(t, errors.Is(e, expectedIsErr))
})
t.Run("errors.As", func(t *testing.T) {
e := QueryError{
RefID: "A",
Err: expectedError{},
}
var expectedAsError expectedError
assert.True(t, errors.As(e, &expectedAsError))
})
}
Computing file changes ...