MVP: 按 07 风格重写前端 + Go 后端落地(长文/短文、编辑器、后台管理)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package db
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRebind(t *testing.T) {
|
||||
sqlite := &DB{Dialect: SQLite}
|
||||
pg := &DB{Dialect: Postgres}
|
||||
|
||||
q := "SELECT * FROM posts WHERE kind = ? AND status = ? LIMIT ? OFFSET ?"
|
||||
|
||||
if got := sqlite.Rebind(q); got != q {
|
||||
t.Errorf("sqlite must keep ? placeholders, got %q", got)
|
||||
}
|
||||
|
||||
want := "SELECT * FROM posts WHERE kind = $1 AND status = $2 LIMIT $3 OFFSET $4"
|
||||
if got := pg.Rebind(q); got != want {
|
||||
t.Errorf("postgres rebind:\n got %q\nwant %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoInc(t *testing.T) {
|
||||
if got := (&DB{Dialect: SQLite}).AutoInc(); got != "INTEGER PRIMARY KEY AUTOINCREMENT" {
|
||||
t.Errorf("sqlite autoincrement = %q", got)
|
||||
}
|
||||
if got := (&DB{Dialect: Postgres}).AutoInc(); got != "BIGSERIAL PRIMARY KEY" {
|
||||
t.Errorf("postgres autoincrement = %q", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user