@@ -43,13 +43,13 @@ func TestErrorsStrictIgnoreNotes(t *testing.T) {
43
43
}
44
44
45
45
func TestMySQLErrIs (t * testing.T ) {
46
- infraErr := & MySQLError {1234 , "the server is on fire" }
47
- otherInfraErr := & MySQLError {1234 , "the datacenter is flooded" }
46
+ infraErr := & MySQLError {1234 , "" , " the server is on fire" }
47
+ otherInfraErr := & MySQLError {1234 , "" , " the datacenter is flooded" }
48
48
if ! errors .Is (infraErr , otherInfraErr ) {
49
49
t .Errorf ("expected errors to be the same: %+v %+v" , infraErr , otherInfraErr )
50
50
}
51
51
52
- differentCodeErr := & MySQLError {5678 , "the server is on fire" }
52
+ differentCodeErr := & MySQLError {5678 , "" , " the server is on fire" }
53
53
if errors .Is (infraErr , differentCodeErr ) {
54
54
t .Fatalf ("expected errors to be different: %+v %+v" , infraErr , differentCodeErr )
55
55
}
@@ -59,3 +59,16 @@ func TestMySQLErrIs(t *testing.T) {
59
59
t .Fatalf ("expected errors to be different: %+v %+v" , infraErr , nonMysqlErr )
60
60
}
61
61
}
62
+
63
+ func TestMySQLErrIsWithSQLState (t * testing.T ) {
64
+ infraErr := & MySQLError {1234 , "HY000" , "the server is on fire" }
65
+ otherInfraErr := & MySQLError {1234 , "HY000" , "the datacenter is flooded" }
66
+ if ! infraErr .IsWithSQLState (otherInfraErr ) {
67
+ t .Errorf ("expected errors to be the same: %+v %+v" , infraErr , otherInfraErr )
68
+ }
69
+
70
+ differentCodeErr := & MySQLError {1234 , "42000" , "the server is on fire" }
71
+ if infraErr .IsWithSQLState (differentCodeErr ) {
72
+ t .Fatalf ("expected errors to be different: %+v %+v" , infraErr , differentCodeErr )
73
+ }
74
+ }
0 commit comments