From dba57a15a85a16273708ffde0f7f8103735e263f Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Fri, 1 Sep 2017 14:11:09 +0100 Subject: [PATCH] removed embed init() for unit testing --- domain/space/space_test.go | 2 +- domain/test/test.go | 8 ++++++-- edition/community.go | 7 ++++++- embed/embed.go | 11 ++++++++--- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/domain/space/space_test.go b/domain/space/space_test.go index 414a35c4..10bba5a0 100644 --- a/domain/space/space_test.go +++ b/domain/space/space_test.go @@ -38,7 +38,7 @@ func TestAddSpace(t *testing.T) { return } - if sp != sp2 { + if sp.Name != sp2.Name { t.Errorf("Test Failed, space one (%v) does not match space 2(%v)", sp, sp2) } } diff --git a/domain/test/test.go b/domain/test/test.go index 99676c6b..415560cf 100644 --- a/domain/test/test.go +++ b/domain/test/test.go @@ -7,6 +7,8 @@ import ( "github.com/documize/community/domain" "github.com/documize/community/edition/boot" "github.com/documize/community/edition/logging" + "github.com/documize/community/embed" + "github.com/documize/community/server/web" _ "github.com/go-sql-driver/mysql" // testing ) @@ -20,7 +22,9 @@ func SetupTest() (rt *env.Runtime, s *domain.Store, ctx domain.RequestContext) { func startRuntime() (rt *env.Runtime, s *domain.Store) { rt = new(env.Runtime) s = new(domain.Store) + rt.Log = logging.NewLogger() + web.Embed = embed.NewEmbedder() rt.Product = env.ProdInfo{} rt.Product.Major = "0" @@ -53,7 +57,7 @@ func setupContext() domain.RequestContext { ctx.Guest = false ctx.Editor = true ctx.Global = true - ctx.UserID = "1" - ctx.OrgID = "1" + ctx.UserID = "test" + ctx.OrgID = "test" return ctx } diff --git a/edition/community.go b/edition/community.go index 7e126a6b..5192e582 100644 --- a/edition/community.go +++ b/edition/community.go @@ -20,8 +20,10 @@ import ( "github.com/documize/community/domain/section" "github.com/documize/community/edition/boot" "github.com/documize/community/edition/logging" - _ "github.com/documize/community/embed" // the compressed front-end code and static data + "github.com/documize/community/embed" + // _"github.com/documize/community/embed" // the compressed front-end code and static data "github.com/documize/community/server" + "github.com/documize/community/server/web" _ "github.com/go-sql-driver/mysql" // the mysql driver is required behind the scenes ) @@ -34,6 +36,9 @@ func main() { // wire up logging implementation rt.Log = logging.NewLogger() + // wire up embedded web assets handler + web.Embed = embed.NewEmbedder() + // product details rt.Product = env.ProdInfo{} rt.Product.Major = "1" diff --git a/embed/embed.go b/embed/embed.go index 9d6fd668..f1b1b2a4 100644 --- a/embed/embed.go +++ b/embed/embed.go @@ -17,7 +17,6 @@ package embed import ( "net/http" - "github.com/documize/community/server/web" assetfs "github.com/elazarl/go-bindata-assetfs" ) @@ -38,6 +37,12 @@ func (embedderT) StaticAssetsFileSystem() http.FileSystem { var embedder embedderT -func init() { - web.Embed = embedder +// NewEmbedder returns embed assets handler instance +func NewEmbedder() embedderT { + return embedder } + +// func init() { +// fmt.Println("firing embed init()") +// web.Embed = embedder +// }