You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
paopao-ce/internal/dao/sakila/sqlx_test.go

52 lines
1.3 KiB

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))
}
})
})