github.com/lingyao2333/mo-zero@v1.4.1/zrpc/internal/codes/accept_test.go (about) 1 package codes 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "google.golang.org/grpc/codes" 8 "google.golang.org/grpc/status" 9 ) 10 11 func TestAccept(t *testing.T) { 12 tests := []struct { 13 name string 14 err error 15 accept bool 16 }{ 17 { 18 name: "nil error", 19 err: nil, 20 accept: true, 21 }, 22 { 23 name: "deadline error", 24 err: status.Error(codes.DeadlineExceeded, "deadline"), 25 accept: false, 26 }, 27 } 28 29 for _, test := range tests { 30 t.Run(test.name, func(t *testing.T) { 31 assert.Equal(t, test.accept, Acceptable(test.err)) 32 }) 33 } 34 }