mirror of
https://github.com/documize/community.git
synced 2025-07-19 13:19:43 +02:00
PostgreSQL prep
Update of vendored SQL libs and refactoring of store provider layer.
This commit is contained in:
parent
d0e005f638
commit
b455e5eaf5
105 changed files with 10949 additions and 2376 deletions
|
@ -12,36 +12,37 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"github.com/documize/community/core/env"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// go test github.com/documize/community/core/database -run TestGetVersion
|
||||
func TestGetVersion(t *testing.T) {
|
||||
ts2(t, "5.7.10", []int{5, 7, 10})
|
||||
ts2(t, "5.7.10-log", []int{5, 7, 10})
|
||||
ts2(t, "5.7.10-demo", []int{5, 7, 10})
|
||||
ts2(t, "5.7.10-debug", []int{5, 7, 10})
|
||||
ts2(t, "5.7.16-10", []int{5, 7, 16})
|
||||
ts2(t, "5.7.12-0ubuntu0-12.12.3", []int{5, 7, 12})
|
||||
ts2(t, "10.1.20-MariaDB-1~jessie", []int{10, 1, 20})
|
||||
ts2(t, "ubuntu0-12.12.3", []int{0, 0, 0})
|
||||
ts2(t, "junk-string", []int{0, 0, 0})
|
||||
ts2(t, "somethingstring", []int{0, 0, 0})
|
||||
}
|
||||
// func TestGetVersion(t *testing.T) {
|
||||
// ts2(t, "5.7.10", []int{5, 7, 10})
|
||||
// ts2(t, "5.7.10-log", []int{5, 7, 10})
|
||||
// ts2(t, "5.7.10-demo", []int{5, 7, 10})
|
||||
// ts2(t, "5.7.10-debug", []int{5, 7, 10})
|
||||
// ts2(t, "5.7.16-10", []int{5, 7, 16})
|
||||
// ts2(t, "5.7.12-0ubuntu0-12.12.3", []int{5, 7, 12})
|
||||
// ts2(t, "10.1.20-MariaDB-1~jessie", []int{10, 1, 20})
|
||||
// ts2(t, "ubuntu0-12.12.3", []int{0, 0, 0})
|
||||
// ts2(t, "junk-string", []int{0, 0, 0})
|
||||
// ts2(t, "somethingstring", []int{0, 0, 0})
|
||||
// }
|
||||
|
||||
func ts2(t *testing.T, in string, out []int) {
|
||||
got, _ := GetSQLVersion(in)
|
||||
// func ts2(t *testing.T, in string, out []int) {
|
||||
// got, _ := GetSQLVersion(in)
|
||||
|
||||
// if err != nil {
|
||||
// t.Errorf("Unable to GetSQLVersion %s", err)
|
||||
// }
|
||||
// // if err != nil {
|
||||
// // t.Errorf("Unable to GetSQLVersion %s", err)
|
||||
// // }
|
||||
|
||||
for k, v := range got {
|
||||
if v != out[k] {
|
||||
t.Errorf("version input of %s got %d for position %d but expected %d\n", in, v, k, out[k])
|
||||
}
|
||||
}
|
||||
}
|
||||
// for k, v := range got {
|
||||
// if v != out[k] {
|
||||
// t.Errorf("version input of %s got %d for position %d but expected %d\n", in, v, k, out[k])
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
func TestDatabaseVersionLegacy(t *testing.T) {
|
||||
i := extractVersionNumber("db_00021.sql")
|
||||
|
@ -59,3 +60,15 @@ func TestDatabaseVersionLegacy(t *testing.T) {
|
|||
t.Errorf("expected 26 got %d", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParamRebind(t *testing.T) {
|
||||
q1in := "INSERT INTO dmz_org (c_refid, c_company, c_title) VALUES (?, ?, ?)"
|
||||
q1out := "INSERT INTO dmz_org (c_refid, c_company, c_title) VALUES ($1, $2, $3)"
|
||||
|
||||
test1 := RebindParams(q1in, env.StoreTypePostgreSQL)
|
||||
if test1 != q1out {
|
||||
t.Errorf("expected %s got %s", q1in, test1)
|
||||
}
|
||||
|
||||
t.Log(test1)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue