Skip to content

Commit

Permalink
Validate GetSystemErrorCode
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Jun 16, 2016
1 parent 3c03ea7 commit e5dbff9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions errors_test.go
Expand Up @@ -21,6 +21,7 @@
package tchannel

import (
"io"
"regexp"
"testing"

Expand Down Expand Up @@ -50,3 +51,18 @@ func TestErrorMetricKeys(t *testing.T) {
// Unexpected codes may have poorly-formed keys.
assert.Equal(t, "SystemErrCode(13)", SystemErrCode(13).MetricsKey(), "Expected invalid error codes to use a fallback metrics key format.")
}

func TestInvalidError(t *testing.T) {
code := GetSystemErrorCode(nil)
assert.Equal(t, ErrCodeInvalid, code, "nil error should produce ErrCodeInvalid")
}

func TestUnexpectedError(t *testing.T) {
code := GetSystemErrorCode(io.EOF)
assert.Equal(t, ErrCodeUnexpected, code, "non-tchannel SystemError should produce ErrCodeUnexpected")
}

func TestSystemError(t *testing.T) {
code := GetSystemErrorCode(ErrTimeout)
assert.Equal(t, ErrCodeTimeout, code, "tchannel timeout error produces ErrCodeTimeout")
}

0 comments on commit e5dbff9

Please sign in to comment.