mirror of https://github.com/rocboss/paopao-ce
parent
430df7a15f
commit
a80739239f
@ -0,0 +1,13 @@
|
||||
package sakila_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func TestSakila(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Sakila Suite")
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package sakila_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/dao/sakila"
|
||||
)
|
||||
|
||||
var _ = Describe("Sqlx", Ordered, func() {
|
||||
type queries []struct {
|
||||
originQuery string
|
||||
fixedQuery string
|
||||
}
|
||||
var samples queries
|
||||
|
||||
BeforeAll(func() {
|
||||
samples = queries{
|
||||
{
|
||||
originQuery: `SELECT * FROM @user WHERE username=?@_`,
|
||||
fixedQuery: `SELECT * FROM user WHERE username=?_`,
|
||||
},
|
||||
{
|
||||
originQuery: `SELECT * FROM @user WHERE username=?`,
|
||||
fixedQuery: `SELECT * FROM user WHERE username=?`,
|
||||
},
|
||||
{
|
||||
originQuery: `SELECT * FROM @@user WHERE 用户名=?`,
|
||||
fixedQuery: `SELECT * FROM @@user WHERE 用户名=?`,
|
||||
},
|
||||
{
|
||||
originQuery: `SELECT * FROM @@user, @@@@contact WHERE 用户名=?`,
|
||||
fixedQuery: `SELECT * FROM @@user, @@@@contact WHERE 用户名=?`,
|
||||
},
|
||||
{
|
||||
originQuery: `SELECT @@name, @@@@@id FROM @@user, @@@@contact WHERE 用户名=?`,
|
||||
fixedQuery: `SELECT @@name, @@@@@id FROM @@user, @@@@contact WHERE 用户名=?`,
|
||||
},
|
||||
{
|
||||
originQuery: `SELECT @name, @id FROM @user, @contact WHERE 用户名=?`,
|
||||
fixedQuery: `SELECT name, id FROM user, contact WHERE 用户名=?`,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
It("test internal t func", func() {
|
||||
for _, t := range samples {
|
||||
Expect(sakila.FnTest_t(t.originQuery)).To(Equal(t.fixedQuery))
|
||||
}
|
||||
})
|
||||
})
|
Loading…
Reference in new issue