This commit is contained in:
toom1996
2026-09-07 00:04:01 +08:00
parent 6a5a4378ab
commit 10d8a96e8c
29 changed files with 5349 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package repository
import "testing"
// 仅覆盖纯函数助手(DB 相关方法需 MySQL,本环境不跑)。
func TestContainsAny(t *testing.T) {
if !containsAny("Error 1062: Duplicate entry", "1062") {
t.Fatal("should detect mysql 1062")
}
if !containsAny("UNIQUE constraint failed", "UNIQUE constraint failed") {
t.Fatal("should detect sqlite unique")
}
if containsAny("something else", "1062") {
t.Fatal("should not false-positive")
}
}
func TestIndexOf(t *testing.T) {
if indexOf("abcde", "cd") != 2 {
t.Fatal("indexOf mismatch")
}
if indexOf("abc", "z") != -1 {
t.Fatal("indexOf should return -1")
}
}