Files
im_server/server/db/mysql/adapter_pxc_test.go
T

36 lines
999 B
Go

//go:build mysql
package mysql
import (
"errors"
"testing"
ms "github.com/go-sql-driver/mysql"
)
func TestPXCStrictModeNamedLockError(t *testing.T) {
err := &ms.MySQLError{
Number: 1105,
Message: "Percona-XtraDB-Cluster prohibits use of GET_LOCK with pxc_strict_mode = ENFORCING",
}
if !isPXCStrictModeNamedLockError(err) {
t.Fatal("expected PXC GET_LOCK strict mode error to be recognized")
}
err = &ms.MySQLError{
Number: 1105,
Message: "Percona-XtraDB-Cluster prohibits use of RELEASE_LOCK with pxc_strict_mode = ENFORCING",
}
if !isPXCStrictModeNamedLockError(err) {
t.Fatal("expected PXC RELEASE_LOCK strict mode error to be recognized")
}
if isPXCStrictModeNamedLockError(&ms.MySQLError{Number: 1062, Message: "Duplicate entry"}) {
t.Fatal("duplicate errors must not be recognized as PXC named lock errors")
}
if isPXCStrictModeNamedLockError(errors.New("GET_LOCK failed")) {
t.Fatal("generic errors must not be recognized as PXC named lock errors")
}
}