cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.81.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

internal/promapi/errors_test.go

35lines · modecode

1package promapi
2
3import (
4 "testing"
5
6 v1 "github.com/prometheus/client_golang/api/prometheus/v1"
7 "github.com/stretchr/testify/require"
8)
9
10func 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