test(utils): 添加事件驱动模型测试
- 在 sqrt_test.go 中添加了 fastSqr1 测试函数,用于测试事件驱动模型 - 新增了 Event 和 Uint32AsyncEvent 类型用于测试 - 更新了 go.work、go.mod 和
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package request_reply
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/badu/bus/test_scenarios/request-reply-with-cancellation/orders"
|
||||
)
|
||||
|
||||
func TestRequestReplyWithCancellation(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*1)
|
||||
svc := orders.NewService()
|
||||
orders.NewRepository()
|
||||
|
||||
response, err := svc.CreateOrder(ctx, []int{1, 2, 3})
|
||||
switch err {
|
||||
default:
|
||||
t.Fatalf("error : it supposed to timeout, but it responded %#v and the error is %#v", response, err)
|
||||
case context.DeadlineExceeded:
|
||||
// what we were expecting
|
||||
}
|
||||
|
||||
cancel()
|
||||
}
|
||||
Reference in New Issue
Block a user