package util import ( "context" "testing" "time" ) func TestWithTimeout(t *testing.T) { ctx, cancel := WithTimeout(context.Background(), 0) defer cancel() if _, ok := ctx.Deadline(); ok { t.Error("timeout 0 set a deadline") } ctx, cancel = WithTimeout(context.Background(), time.Minute) defer cancel() if _, ok := ctx.Deadline(); !ok { t.Error("timeout 1m set no deadline") } }