本文整理汇总了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)
}
开发者ID:8legd,项目名称:qor-qor,代码行数:25,代码来源:setup_test.go
示例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)
}
}
开发者ID:qor,项目名称:validations,代码行数:11,代码来源:validation_test.go
示例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{})
}
开发者ID:8legd,项目名称:qor-sorting,代码行数:11,代码来源:sorting_test.go
示例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"})
}
开发者ID:NeoChow,项目名称:qor,代码行数:11,代码来源:exchange_test.go
示例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{})
}
开发者ID:eryx,项目名称:qor,代码行数:12,代码来源:publish_test.go
示例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)
}
开发者ID:8legd,项目名称:qor-qor,代码行数:12,代码来源:transition_test.go
示例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")
}
开发者ID:eryx,项目名称:qor,代码行数:14,代码来源:struct_test.go
示例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)
}
}
开发者ID:qor,项目名称:publish,代码行数:20,代码来源:publish_test.go
示例9: init
func init() {
db = utils.TestDB()
db.AutoMigrate(&User{}, &Product{})
audited.RegisterCallbacks(db)
}
开发者ID:JosephBuchma,项目名称:qor,代码行数:5,代码来源:audited_test.go
示例10: init
func init() {
db = utils.TestDB()
sorting.RegisterCallbacks(db)
db.DropTable(&User{})
db.AutoMigrate(&User{})
}
开发者ID:JosephBuchma,项目名称:qor,代码行数:6,代码来源:sorting_test.go
示例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 {
开发者ID:qor,项目名称:media_library,代码行数:31,代码来源:filesystem_test.go
示例12: init
func init() {
db = utils.TestDB()
db.DropTable(&database.Translation{})
backend = database.New(db)
}
开发者ID:qor,项目名称:i18n,代码行数:5,代码来源:database_test.go
示例13: init
func init() {
db = utils.TestDB()
reset()
}
开发者ID:qor,项目名称:i18n,代码行数:4,代码来源:exchange_actions_test.go
示例14: init
func init() {
db = utils.TestDB()
validations.RegisterCallbacks(db)
db.AutoMigrate(&User{}, &Company{}, &CreditCard{}, &Address{}, &Language{})
}
开发者ID:kennylixi,项目名称:qor,代码行数:5,代码来源:validation_test.go
示例15: init
func init() {
db = utils.TestDB()
db.AutoMigrate(&Seo{}, &Category{})
}
开发者ID:qor,项目名称:seo,代码行数:4,代码来源:seo_test.go
注:本文中的github.com/qor/qor/test/utils.TestDB函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论