Example #1
0
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)
}
Example #2
0
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)
	}
}
Example #3
0
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{})
}
Example #4
0
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"})
}
Example #5
0
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{})
}
Example #6
0
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)
}
Example #7
0
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")
}
Example #8
0
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)
	}
}
Example #9
0
func init() {
	db = utils.TestDB()
	db.AutoMigrate(&User{}, &Product{})
	audited.RegisterCallbacks(db)
}
Example #10
0
func init() {
	db = utils.TestDB()
	sorting.RegisterCallbacks(db)
	db.DropTable(&User{})
	db.AutoMigrate(&User{})
}
Example #11
0
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 {
Example #12
0
func init() {
	db = utils.TestDB()
	db.DropTable(&database.Translation{})
	backend = database.New(db)
}
Example #13
0
func init() {
	db = utils.TestDB()
	reset()
}
Example #14
0
func init() {
	db = utils.TestDB()
	validations.RegisterCallbacks(db)
	db.AutoMigrate(&User{}, &Company{}, &CreditCard{}, &Address{}, &Language{})
}
Example #15
0
File: seo_test.go Project: qor/seo
func init() {
	db = utils.TestDB()
	db.AutoMigrate(&Seo{}, &Category{})
}