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) }
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) } }
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{}) }
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"}) }
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{}) }
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) }
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") }
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) } }
func init() { db = utils.TestDB() db.AutoMigrate(&User{}, &Product{}) audited.RegisterCallbacks(db) }
func init() { db = utils.TestDB() sorting.RegisterCallbacks(db) db.DropTable(&User{}) db.AutoMigrate(&User{}) }
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 {
func init() { db = utils.TestDB() db.DropTable(&database.Translation{}) backend = database.New(db) }
func init() { db = utils.TestDB() reset() }
func init() { db = utils.TestDB() validations.RegisterCallbacks(db) db.AutoMigrate(&User{}, &Company{}, &CreditCard{}, &Address{}, &Language{}) }
func init() { db = utils.TestDB() db.AutoMigrate(&Seo{}, &Category{}) }