fix test
This commit is contained in:
parent
6ee9ed8aa5
commit
b59e8bc5c6
|
@ -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
|
||||
|
|
11
test/main.go
11
test/main.go
|
@ -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
|
||||
|
|
Reference in New Issue