func (s *ServiceSuite) SetUpTest(c *C) {
	s.Session = s.DBServer.Session()
	s.Database = s.Session.DB("riskservice-test")
	s.Service = NewReferenceRiskService(s.Database)

	e := echo.New()
	server.RegisterRoutes(e, make(map[string][]echo.Middleware), server.NewMongoDataAccessLayer(s.Database), server.Config{})
	s.Server = httptest.NewServer(e.Router())
}
Esempio n. 2
0
// runs once
func (s *ServerSuite) SetUpSuite(c *C) {
	var err error

	s.Server = fhir_svr.NewServer("localhost")

	var mongoSession *mgo.Session
	// Set up the database
	if mongoSession, err = mgo.Dial("localhost"); err != nil {
		logger.Log.Error("Cannot connect to MongoDB. Is service running?")
		panic(err)
	}
	c.Assert(mongoSession, NotNil)
	database := mongoSession.DB("ptmatch-test")
	fhir_svr.Database = database

	Setup(s.Server.Engine)
	recMatchWatch := middleware.PostProcessRecordMatchResponse()
	s.Server.AddMiddleware("Bundle", recMatchWatch)

	fhir_svr.RegisterRoutes(s.Server.Engine,
		s.Server.MiddlewareConfig, fhir_svr.NewMongoDataAccessLayer(database),
		fhir_svr.Config{})
}