chore: add tests (#3921)

This commit is contained in:
Kevin Wan
2024-02-20 10:11:43 +08:00
committed by GitHub
parent 6be37ad533
commit 25a807afb2
2 changed files with 12 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/breaker"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -27,3 +28,12 @@ func TestUnaryBreakerInterceptor(t *testing.T) {
})
assert.NotNil(t, err)
}
func TestUnaryBreakerInterceptor_Unavailable(t *testing.T) {
_, err := UnaryBreakerInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
FullMethod: "any",
}, func(_ context.Context, _ any) (any, error) {
return nil, breaker.ErrServiceUnavailable
})
assert.NotNil(t, err)
}