liuhaijun 3f5f28d785 add sheduling agent
Change-Id: I89f35fb3984044c57f10727432755012542f9fd8
2023-11-16 10:55:57 +00:00

24 lines
589 B
Go

package utility
import "testing"
func TestLazy_Value(t *testing.T) {
i := 0
someLazyValue := NewLazy(func() (value interface{}, err error) {
value = "some lazy value"
i++
return
})
var theValueOfSomeLazyValue string
if err := someLazyValue.Value(&theValueOfSomeLazyValue); err != nil {
t.Fatalf("get value failed, %s", err)
}
t.Logf("value of lazy: %s", theValueOfSomeLazyValue)
if err := someLazyValue.Value(&theValueOfSomeLazyValue); err != nil {
t.Fatalf("get value failed, %s", err)
}
if i > 1 {
t.Fatalf("lazy should only evaluate once, but %d times", i)
}
}