From 02b509e0a4a9c5f4cc2515918c40f8f219aa8c5d Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 6 Aug 2020 23:13:33 +0800 Subject: [PATCH] add tests --- rpcx/internal/codes/accept_test.go | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 rpcx/internal/codes/accept_test.go diff --git a/rpcx/internal/codes/accept_test.go b/rpcx/internal/codes/accept_test.go new file mode 100644 index 00000000..ddca4a08 --- /dev/null +++ b/rpcx/internal/codes/accept_test.go @@ -0,0 +1,34 @@ +package codes + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func TestAccept(t *testing.T) { + tests := []struct { + name string + err error + accept bool + }{ + { + name: "nil error", + err: nil, + accept: true, + }, + { + name: "deadline error", + err: status.Error(codes.DeadlineExceeded, "deadline"), + accept: false, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + assert.Equal(t, test.accept, Acceptable(test.err)) + }) + } +}