sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0
This commit is contained in:
Martin Geno 2016-10-12 12:44:56 +02:00
parent 6ee9ed8aa5
commit b59e8bc5c6
2 changed files with 7 additions and 6 deletions

View File

@ -9,7 +9,7 @@ import (
func TestAPI(t *testing.T) {
assert, config, sessions, db, router := test.Init(t)
assert, db, router := test.Init(t)
defer db.Close()
//load system Models to database

View File

@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httptest"
"testing"
"os"
"github.com/astaxie/session"
_ "github.com/astaxie/session/providers/memory"
@ -20,10 +21,10 @@ import (
)
//Init to initialisieren a API
func Init(t *testing.T) (assertion *assert.Assertions, config *libconfig.Config, sessions *session.Manager, dbconnection *gorm.DB, router *goji.Mux) {
func Init(t *testing.T) (assertion *assert.Assertions, dbconnection *gorm.DB, router *goji.Mux) {
assertion = assert.New(t)
config = libconfig.ReadConfigFile("../cmd/warehost/config.yml.example")
log.NewLogger(config.Log.Path)
libconfig.ReadConfigFile(os.Getenv("GOPATH") +"/src/dev.sum7.eu/sum7/warehost/cmd/warehost/config.yml.example")
log.NewLogger(libconfig.Data.Log.Path)
// Session mgmt
sessions, err := session.NewManager("memory", "session", 3600)
@ -31,13 +32,13 @@ func Init(t *testing.T) (assertion *assert.Assertions, config *libconfig.Config,
assertion.NoError(err)
// Database
dbconnection, err = gorm.Open("postgres", config.Database)
dbconnection, err = gorm.Open("postgres", libconfig.Data.Database)
assertion.NoError(err)
dbconnection.Callback().Create().Remove("gorm:update_time_stamp")
dbconnection.Callback().Update().Remove("gorm:update_time_stamp")
dbconnection.SingularTable(true)
dbconnection.LogMode(config.DatabaseDebug)
dbconnection.LogMode(libconfig.Data.DatabaseDebug)
router = goji.NewMux()
return