mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-28 07:36:38 +08:00
3d1a8c8963
Reduce repetitive raw SQL in test bodies by routing scalar and multi-column checks through shared helpers, keeping test intent clearer without changing behavior.
20 lines
417 B
Go
20 lines
417 B
Go
package contract
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"go-backend/internal/store/repo"
|
|
)
|
|
|
|
func mustLastInsertID(t *testing.T, r *repo.Repository, label string) int64 {
|
|
t.Helper()
|
|
var id int64
|
|
if err := r.DB().Raw("SELECT last_insert_rowid()").Row().Scan(&id); err != nil {
|
|
t.Fatalf("read last_insert_rowid for %s: %v", label, err)
|
|
}
|
|
if id <= 0 {
|
|
t.Fatalf("invalid last_insert_rowid for %s: %d", label, id)
|
|
}
|
|
return id
|
|
}
|