package monitor import ( g "leafstalk/module/go" "sync" "testing" "time" ) func TestGoLoadTimeoutWarn(t *testing.T) { st := time.Now() d := g.New(0) wg := sync.WaitGroup{} // go 1 var res int d.Go(func() { wg.Add(1) t.Log("1 + 1 = ?") res = 1 + 1 time.Sleep(2 * time.Second) }, func() { t.Log(res) GoLoadTimeoutWarn("TestGoLoadTimeoutWarn", 123, st) wg.Done() }) wg.Wait() d.Close() } func TestTimeoutWarnCall(t *testing.T) { args := 123 f := func() { time.Sleep(2 * time.Second) t.Log(args) } TimeoutWarnCall(f, "TestTimeoutWarnCall", args, AlarmTypeMySqlExec, time.Now()) }