gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/lifecycle/task/task_test.go (about)

     1  package task
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func handleError(ep *error) {
     9  	e := recover()
    10  	if err, is := e.(error); is {
    11  		*ep = err
    12  	} else {
    13  		panic(e)
    14  	}
    15  }
    16  
    17  func run() (err error) {
    18  	defer handleError(&err)
    19  	panic("test")
    20  }
    21  
    22  func TestNewTaskExecutor(t *testing.T) {
    23  	fmt.Println(run())
    24  }