Ejemplo n.º 1
0
func (s *MySuite) TestRemoveMailThreadWithSingleReference(c *C) {

	session, err := mgo.Dial("localhost")
	c.Assert(err, IsNil)
	defer session.Close()
	coll := session.DB(mailBox).C(threadsCollection)

	var mail mail.Mail
	mail.Init()
	mail.From = bson.NewObjectId()
	mail.Subject = "Hello world"
	mail.Mailtext = "Long mail text"
	mailThreadId, errr := CreateNewMailThread(coll, &mail)
	c.Assert(errr, Equals, true)
	retval := DeleteMailThread(coll, mailThreadId)

	c.Assert(retval, Equals, true)
	_, err = findMailThread(coll, mailThreadId)
	c.Assert(err, NotNil)

}
Ejemplo n.º 2
0
func (s *MySuite) TestCreateEmptyMailThread(c *C) {

	session, err := mgo.Dial("localhost")
	c.Assert(err, IsNil)
	defer session.Close()
	coll := session.DB(mailBox).C(threadsCollection)

	var mail mail.Mail
	mail.Init()
	threadId, retval := CreateNewMailThread(coll, &mail)
	c.Assert(retval, Equals, true)

	var mailThread MailThread
	err = coll.FindId(threadId).One(&mailThread)
	c.Assert(err, IsNil)
	c.Assert(mailThread.Id, Equals, threadId)
	c.Assert(mailThread.ReferenceCount, Equals, 0)
	c.Assert(len(mailThread.Mails), Equals, 1)

	// TODO figure out why nsec is not same :(
	//c.Assert(mailThread.Mails[0], DeepEquals, mail)
}