Export struct sliceValidateError to allow error casting and rename it as (#2777)
SliceValidationError Co-authored-by: Emeric de Bernis <emeric.debernis@adevinta.com>
This commit is contained in:
@@ -9,24 +9,24 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSliceValidateError(t *testing.T) {
|
||||
func TestSliceValidationError(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
err sliceValidateError
|
||||
err SliceValidationError
|
||||
want string
|
||||
}{
|
||||
{"has nil elements", sliceValidateError{errors.New("test error"), nil}, "[0]: test error"},
|
||||
{"has zero elements", sliceValidateError{}, ""},
|
||||
{"has one element", sliceValidateError{errors.New("test one error")}, "[0]: test one error"},
|
||||
{"has nil elements", SliceValidationError{errors.New("test error"), nil}, "[0]: test error"},
|
||||
{"has zero elements", SliceValidationError{}, ""},
|
||||
{"has one element", SliceValidationError{errors.New("test one error")}, "[0]: test one error"},
|
||||
{"has two elements",
|
||||
sliceValidateError{
|
||||
SliceValidationError{
|
||||
errors.New("first error"),
|
||||
errors.New("second error"),
|
||||
},
|
||||
"[0]: first error\n[1]: second error",
|
||||
},
|
||||
{"has many elements",
|
||||
sliceValidateError{
|
||||
SliceValidationError{
|
||||
errors.New("first error"),
|
||||
errors.New("second error"),
|
||||
nil,
|
||||
@@ -40,7 +40,7 @@ func TestSliceValidateError(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.err.Error(); got != tt.want {
|
||||
t.Errorf("sliceValidateError.Error() = %v, want %v", got, tt.want)
|
||||
t.Errorf("SliceValidationError.Error() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user