cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
internal/promapi/errors_test.go
35lines · modecode
| 1 | package promapi |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | v1 "github.com/prometheus/client_golang/api/prometheus/v1" |
| 7 | "github.com/stretchr/testify/require" |
| 8 | ) |
| 9 | |
| 10 | func TestDecodeErrorType(t *testing.T) { |
| 11 | type testCaseT struct { |
| 12 | input string |
| 13 | expected v1.ErrorType |
| 14 | } |
| 15 | |
| 16 | testCases := []testCaseT{ |
| 17 | {input: "bad_data", expected: v1.ErrBadData}, |
| 18 | {input: "timeout", expected: v1.ErrTimeout}, |
| 19 | {input: "canceled", expected: v1.ErrCanceled}, |
| 20 | {input: "execution", expected: v1.ErrExec}, |
| 21 | {input: "bad_response", expected: v1.ErrBadResponse}, |
| 22 | {input: "server_error", expected: v1.ErrServer}, |
| 23 | {input: "client_error", expected: v1.ErrClient}, |
| 24 | {input: "unknown_type", expected: ErrUnknown}, |
| 25 | {input: "", expected: ErrUnknown}, |
| 26 | {input: "random", expected: ErrUnknown}, |
| 27 | } |
| 28 | |
| 29 | for _, tc := range testCases { |
| 30 | t.Run(tc.input, func(t *testing.T) { |
| 31 | result := decodeErrorType(tc.input) |
| 32 | require.Equal(t, tc.expected, result) |
| 33 | }) |
| 34 | } |
| 35 | } |
| 36 | |