Ejemplo n.º 1
0
func TestSpec(t *testing.T) {
	Convey("Given a expire time and save it to the database", t, func() {
		curTime := time.Now()
		exp := models.Expire{"76441e7c-310c-405a-89ce-c39bcd288c03", curTime}
		exp.Save()
		temp := GetExpiredTime(exp.DocumentId)
		Convey("Returned expire time should not be empty", func() {
			So(temp, ShouldNotBeEmpty)
		})
		Convey("Expire time should be correctly saved", func() {
			count := isSameTime(temp, timeToDT(exp.ExpireTime))
			So(count, ShouldBeGreaterThan, 19)
		})
		Convey("Expire time should be correctly updated", func() {
			exp.Update(time.Now())
			uTemp := GetExpiredTime(exp.DocumentId)
			count := isSameTime(uTemp, timeToDT(exp.ExpireTime))
			So(count, ShouldBeGreaterThan, 19)
		})
	})
}