feat(core): 下沉查询密码工具与配置快照解码
Verify / verify (push) Canceled after 0s

This commit is contained in:
zhangdeman committed 2026-11-28 03:10:18 -08:00
1 parent bedcf4dd83
commit d2a9033695
23 files changed
+1544 -6

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
//go:build cgo
package dberror
import (
"fmt"
"testing"
"github.com/mattn/go-sqlite3"
)
// TestIsDuplicateKeySQLite 验证CGO驱动约束类型,保留主键/唯一键幂等语义,不吞掉其他约束错误。
func TestIsDuplicateKeySQLite(t *testing.T) {
for _, item := range []struct {
name string
err error
duplicate bool
}{
{name: "unique", err: sqlite3.Error{Code: sqlite3.ErrConstraint, ExtendedCode: sqlite3.ErrConstraintUnique}, duplicate: true},
{name: "wrapped primary", err: fmt.Errorf("write event: %w", sqlite3.Error{Code: sqlite3.ErrConstraint, ExtendedCode: sqlite3.ErrConstraintPrimaryKey}), duplicate: true},
{name: "foreign key", err: sqlite3.Error{Code: sqlite3.ErrConstraint, ExtendedCode: sqlite3.ErrConstraintForeignKey}},
{name: "not null", err: sqlite3.Error{Code: sqlite3.ErrConstraint, ExtendedCode: sqlite3.ErrConstraintNotNull}},
} {
t.Run(item.name, func(t *testing.T) {
if got := IsDuplicateKey(item.err); got != item.duplicate {
t.Fatalf("duplicate=%v want=%v", got, item.duplicate)
}
})
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.