Exemplo n.º 1
0
func (self *Server) Start() {
	fmt.Printf("Connecting to database... ")
	session, err := mgo.Dial("localhost")

	utils.HandleError(err)

	fmt.Println("done.")

	self.listener, err = net.Listen("tcp", ":8945")
	utils.HandleError(err)

	database.Init(database.NewMongoSession(session.Copy()), "mud")
}
Exemplo n.º 2
0
func (s *ModelSuite) SetUpSuite(c *C) {
	session, err := mgo.Dial("localhost")
	c.Assert(err, Equals, nil)

	if err != nil {
		return
	}

	dbName := "unit_model_test"

	_db = session.DB(dbName)

	session.DB(dbName).DropDatabase()

	database.Init(database.NewMongoSession(session), dbName)
}