accept_test.go 565 B

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