예제 #1
0
파일: setup_test.go 프로젝트: 8legd/qor-qor
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
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)
	}
}
예제 #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{})
}
예제 #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"})
}
예제 #5
0
파일: publish_test.go 프로젝트: eryx/qor
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
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)
}
예제 #7
0
파일: struct_test.go 프로젝트: eryx/qor
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
0
파일: publish_test.go 프로젝트: qor/publish
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
0
func init() {
	db = utils.TestDB()
	db.AutoMigrate(&User{}, &Product{})
	audited.RegisterCallbacks(db)
}
예제 #10
0
func init() {
	db = utils.TestDB()
	sorting.RegisterCallbacks(db)
	db.DropTable(&User{})
	db.AutoMigrate(&User{})
}
예제 #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 {
예제 #12
0
파일: database_test.go 프로젝트: qor/i18n
func init() {
	db = utils.TestDB()
	db.DropTable(&database.Translation{})
	backend = database.New(db)
}
예제 #13
0
func init() {
	db = utils.TestDB()
	reset()
}
예제 #14
0
func init() {
	db = utils.TestDB()
	validations.RegisterCallbacks(db)
	db.AutoMigrate(&User{}, &Company{}, &CreditCard{}, &Address{}, &Language{})
}
예제 #15
0
파일: seo_test.go 프로젝트: qor/seo
func init() {
	db = utils.TestDB()
	db.AutoMigrate(&Seo{}, &Category{})
}