fix test
This commit is contained in:
parent
6ee9ed8aa5
commit
b59e8bc5c6
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
func TestAPI(t *testing.T) {
|
func TestAPI(t *testing.T) {
|
||||||
|
|
||||||
assert, config, sessions, db, router := test.Init(t)
|
assert, db, router := test.Init(t)
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
//load system Models to database
|
//load system Models to database
|
||||||
|
|
11
test/main.go
11
test/main.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/astaxie/session"
|
"github.com/astaxie/session"
|
||||||
_ "github.com/astaxie/session/providers/memory"
|
_ "github.com/astaxie/session/providers/memory"
|
||||||
|
@ -20,10 +21,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
//Init to initialisieren a API
|
//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)
|
assertion = assert.New(t)
|
||||||
config = libconfig.ReadConfigFile("../cmd/warehost/config.yml.example")
|
libconfig.ReadConfigFile(os.Getenv("GOPATH") +"/src/dev.sum7.eu/sum7/warehost/cmd/warehost/config.yml.example")
|
||||||
log.NewLogger(config.Log.Path)
|
log.NewLogger(libconfig.Data.Log.Path)
|
||||||
|
|
||||||
// Session mgmt
|
// Session mgmt
|
||||||
sessions, err := session.NewManager("memory", "session", 3600)
|
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)
|
assertion.NoError(err)
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
dbconnection, err = gorm.Open("postgres", config.Database)
|
dbconnection, err = gorm.Open("postgres", libconfig.Data.Database)
|
||||||
assertion.NoError(err)
|
assertion.NoError(err)
|
||||||
|
|
||||||
dbconnection.Callback().Create().Remove("gorm:update_time_stamp")
|
dbconnection.Callback().Create().Remove("gorm:update_time_stamp")
|
||||||
dbconnection.Callback().Update().Remove("gorm:update_time_stamp")
|
dbconnection.Callback().Update().Remove("gorm:update_time_stamp")
|
||||||
dbconnection.SingularTable(true)
|
dbconnection.SingularTable(true)
|
||||||
dbconnection.LogMode(config.DatabaseDebug)
|
dbconnection.LogMode(libconfig.Data.DatabaseDebug)
|
||||||
|
|
||||||
router = goji.NewMux()
|
router = goji.NewMux()
|
||||||
return
|
return
|
||||||
|
|
Reference in New Issue