本文整理汇总了Golang中github.com/qor/qor/test/utils.TestDB函数的典型用法代码示例。如果您正苦于以下问题:Golang TestDB函数的具体用法?Golang TestDB怎么用?Golang TestDB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TestDB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
mux := http.NewServeMux()
db = utils.TestDB()
models := []interface{}{&User{}, &CreditCard{}, &Address{}, &Language{}, &Profile{}, &Phone{}}
for _, value := range models {
db.DropTableIfExists(value)
db.AutoMigrate(value)
}
Admin = admin.New(&qor.Config{DB: db})
user := Admin.AddResource(&User{})
user.Meta(&admin.Meta{Name: "Languages", Type: "select_many",
Collection: func(resource interface{}, context *qor.Context) (results [][]string) {
if languages := []Language{}; !context.GetDB().Find(&languages).RecordNotFound() {
for _, language := range languages {
results = append(results, []string{fmt.Sprint(language.ID), language.Name})
}
}
return
}})
Admin.MountTo("/admin", mux)
server = httptest.NewServer(mux)
}
示例2: init
func init() {
db = utils.TestDB()
validations.RegisterCallbacks(db)
tables := []interface{}{&User{}, &Company{}, &CreditCard{}, &Address{}, &Language{}}
for _, table := range tables {
if err := db.DropTableIfExists(table).Error; err != nil {
panic(err)
}
db.AutoMigrate(table)
}
}
示例3: init
func init() {
db = utils.TestDB()
sorting.RegisterCallbacks(db)
l10n.RegisterCallbacks(db)
pb = publish.New(db)
pb.ProductionDB().DropTable(&User{}, &Product{}, &Brand{})
pb.DraftDB().DropTable(&Product{})
db.AutoMigrate(&User{}, &Product{}, &Brand{})
pb.AutoMigrate(&Product{})
}
示例4: init
func init() {
db = utils.TestDB()
db.DropTable(&Product{})
db.AutoMigrate(&Product{})
product = exchange.NewResource(&Product{}, exchange.Config{PrimaryField: "Code"})
product.Meta(exchange.Meta{Name: "Code"})
product.Meta(exchange.Meta{Name: "Name"})
product.Meta(exchange.Meta{Name: "Price"})
}
示例5: init
func init() {
db = utils.TestDB()
pb = publish.New(db)
pbdraft = pb.DraftDB()
pbprod = pb.ProductionDB()
for _, table := range []string{"products", "products_draft", "colors", "categories", "languages", "product_categories", "product_categories_draft", "languages", "product_languages_draft"} {
pbprod.Exec(fmt.Sprintf("drop table %v", table))
}
pbprod.AutoMigrate(&Product{}, &Color{}, &Category{}, &Language{})
pb.AutoMigrate(&Product{}, &Category{})
}
示例6: TestMain
func TestMain(m *testing.M) {
testdb = utils.TestDB()
ResetDb()
OrderStateMachine.Initial(OrderStateDraft)
OrderStateMachine.Event(OrderEventCheckout).To(OrderStatePaying).From(OrderStateDraft)
test := m.Run()
os.Exit(test)
}
示例7: init
func init() {
db := utils.TestDB()
l10n.RegisterCallbacks(db)
db.DropTableIfExists(&Product{})
db.DropTableIfExists(&Tag{})
db.Exec("drop table product_tags;")
db.AutoMigrate(&Product{})
db.AutoMigrate(&Tag{})
dbGlobal = db
dbCN = dbGlobal.Set("l10n:locale", "zh")
dbEN = dbGlobal.Set("l10n:locale", "en")
}
示例8: init
func init() {
db = utils.TestDB()
l10n.RegisterCallbacks(db)
pb = publish.New(db)
pbdraft = pb.DraftDB()
pbprod = pb.ProductionDB()
for _, table := range []string{"product_categories", "product_categories_draft", "product_languages", "product_languages_draft", "author_books", "author_books_draft"} {
pbprod.Exec(fmt.Sprintf("drop table %v", table))
}
for _, value := range []interface{}{&Product{}, &Color{}, &Category{}, &Language{}, &Book{}, &Publisher{}, &Comment{}, &Author{}} {
pbprod.DropTable(value)
pbdraft.DropTable(value)
pbprod.AutoMigrate(value)
pb.AutoMigrate(value)
}
}
示例9: init
func init() {
db = utils.TestDB()
db.AutoMigrate(&User{}, &Product{})
audited.RegisterCallbacks(db)
}
示例10: init
func init() {
db = utils.TestDB()
sorting.RegisterCallbacks(db)
db.DropTable(&User{})
db.AutoMigrate(&User{})
}
示例11: GetSizes
package media_library_test
import (
"image"
"image/gif"
"os"
"path"
"strings"
"testing"
"github.com/jinzhu/gorm"
"github.com/qor/media_library"
"github.com/qor/qor/test/utils"
)
var db = utils.TestDB()
type MyFileSystem struct {
media_library.FileSystem
}
func (MyFileSystem) GetSizes() map[string]*media_library.Size {
return map[string]*media_library.Size{
"small1": {20, 10},
"small2": {20, 10},
"square": {30, 30},
"big": {50, 50},
}
}
type User struct {
示例12: init
func init() {
db = utils.TestDB()
db.DropTable(&database.Translation{})
backend = database.New(db)
}
示例13: init
func init() {
db = utils.TestDB()
reset()
}
示例14: init
func init() {
db = utils.TestDB()
validations.RegisterCallbacks(db)
db.AutoMigrate(&User{}, &Company{}, &CreditCard{}, &Address{}, &Language{})
}
示例15: init
func init() {
db = utils.TestDB()
db.AutoMigrate(&Seo{}, &Category{})
}