You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package time_arrow
import ( "testing" "time" )
func Test_cache_IsExpired(t *testing.T) { cachet := cache{}
if !cachet.IsExpired() { t.Error("cache should be expired") }
if cachet.IsExpired() { cachet.SetData("hello", time.Second*5) }
time.Sleep(time.Second * 1) data := cachet.GetData() if cachet.IsExpired() { t.Error("cache should not be expired 1") } if data != "hello" { t.Error("cache should not be expired 2") }
time.Sleep(time.Second * 5) data = cachet.GetData() if !cachet.IsExpired() { t.Error("cache should be expired 1 ") } if data != "" { t.Error("cache should be expired 2") } }
|