Files
backend_v2/internal/repository/ingest_repository_test.go
2026-09-20 01:06:13 +08:00

26 lines
646 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package repository
import "testing"
// 仅覆盖纯函数助手(DB 相关方法需连库,本环境不跑)。
func TestContainsAny(t *testing.T) {
if !containsAny("Error 1062: Duplicate entry", "1062") {
t.Fatal("should detect duplicate key (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")
}
}