Пример #1
0
func IsDuplicateExecError(err errs.Err) bool {
	str := err.StandardErrorMessage()
	return strings.HasPrefix(str, "Error 1060: Duplicate column name") ||
		strings.HasPrefix(str, "Error 1061: Duplicate key name") ||
		strings.HasPrefix(str, "Error 1050: Table") ||
		strings.HasPrefix(str, "Error 1022: Can't write; duplicate key in table")
}
Пример #2
0
func TestParallelFinalFuncReturnsError(t *testing.T) {
	var err errs.Err
	err = Parallel(f1, f2, func(res1, res2 string, err errs.Err) {})
	assert(t, err == nil)
	err = Parallel(f1, fErr, func(res1, res2 string, err errs.Err) {})
	assert(t, err != nil)
	err = Parallel(f1, f2, func(res1, res2 string, err errs.Err) errs.Err { return nil })
	assert(t, err == nil)
	err = Parallel(f1, fErr, func(res1, res2 string, err errs.Err) errs.Err { return errors.New("A new errs.Err") })
	assert(t, err != nil)
	assert(t, err.Error() == "A new errs.Err")
	err = Parallel(f1, f2, func(res1, res2 string, err errs.Err) errs.Err { return nil })
	assert(t, err == nil)
}
Пример #3
0
func IsDuplicateEntryError(err errs.Err) bool {
	str := err.StandardErrorMessage()
	return strings.Contains(str, "Duplicate entry")
}