gorm/tests/error_translator_test.go

20 lines
439 B
Go
Raw Normal View History

package tests_test
import (
"errors"
"testing"
"gorm.io/gorm"
"gorm.io/gorm/utils/tests"
)
func TestDialectorWithErrorTranslatorSupport(t *testing.T) {
translatedErr := errors.New("translated error")
db, _ := gorm.Open(tests.DummyDialector{TranslatedErr: translatedErr})
err := db.AddError(errors.New("some random error"))
if !errors.Is(err, translatedErr) {
t.Fatalf("expected err: %v got err: %v", translatedErr, err)
}
}