mirror of
https://github.com/documize/community.git
synced 2025-07-24 07:39:43 +02:00
bumped version
This commit is contained in:
parent
07c8238664
commit
c235fb569e
9 changed files with 819 additions and 664 deletions
59
domain/test/test.go
Normal file
59
domain/test/test.go
Normal file
|
@ -0,0 +1,59 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/edition/boot"
|
||||
"github.com/documize/community/edition/logging"
|
||||
_ "github.com/go-sql-driver/mysql" // testing
|
||||
)
|
||||
|
||||
// SetupTest prepares test environment
|
||||
func SetupTest() (rt *env.Runtime, s *domain.Store, ctx domain.RequestContext) {
|
||||
rt, s = startRuntime()
|
||||
ctx = setupContext()
|
||||
return rt, s, ctx
|
||||
}
|
||||
|
||||
func startRuntime() (rt *env.Runtime, s *domain.Store) {
|
||||
rt = new(env.Runtime)
|
||||
s = new(domain.Store)
|
||||
rt.Log = logging.NewLogger()
|
||||
|
||||
rt.Product = env.ProdInfo{}
|
||||
rt.Product.Major = "0"
|
||||
rt.Product.Minor = "0"
|
||||
rt.Product.Patch = "0"
|
||||
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
||||
rt.Product.Edition = "Test"
|
||||
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
||||
rt.Product.License = env.License{}
|
||||
rt.Product.License.Seats = 1
|
||||
rt.Product.License.Valid = true
|
||||
rt.Product.License.Trial = false
|
||||
rt.Product.License.Edition = "Community"
|
||||
|
||||
// parse settings from command line and environment
|
||||
rt.Flags = env.ParseFlags()
|
||||
boot.InitRuntime(rt, s)
|
||||
|
||||
// section.Register(rt, s)
|
||||
|
||||
return rt, s
|
||||
}
|
||||
|
||||
// setup testing context
|
||||
func setupContext() domain.RequestContext {
|
||||
ctx := domain.RequestContext{}
|
||||
ctx.AllowAnonymousAccess = true
|
||||
ctx.Authenticated = true
|
||||
ctx.Administrator = true
|
||||
ctx.Guest = false
|
||||
ctx.Editor = true
|
||||
ctx.Global = true
|
||||
ctx.UserID = "1"
|
||||
ctx.OrgID = "1"
|
||||
return ctx
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue