(t *testing.T)
| 4633 | } |
| 4634 | |
| 4635 | func TestReturnAPIError(t *testing.T) { |
| 4636 | cases := []struct { |
| 4637 | err error |
| 4638 | expected errorType |
| 4639 | }{ |
| 4640 | { |
| 4641 | err: promql.ErrStorage{Err: errors.New("storage error")}, |
| 4642 | expected: errorInternal, |
| 4643 | }, { |
| 4644 | err: fmt.Errorf("wrapped: %w", promql.ErrStorage{Err: errors.New("storage error")}), |
| 4645 | expected: errorInternal, |
| 4646 | }, { |
| 4647 | err: promql.ErrQueryTimeout("timeout error"), |
| 4648 | expected: errorTimeout, |
| 4649 | }, { |
| 4650 | err: fmt.Errorf("wrapped: %w", promql.ErrQueryTimeout("timeout error")), |
| 4651 | expected: errorTimeout, |
| 4652 | }, { |
| 4653 | err: promql.ErrQueryCanceled("canceled error"), |
| 4654 | expected: errorCanceled, |
| 4655 | }, { |
| 4656 | err: fmt.Errorf("wrapped: %w", promql.ErrQueryCanceled("canceled error")), |
| 4657 | expected: errorCanceled, |
| 4658 | }, { |
| 4659 | err: errors.New("exec error"), |
| 4660 | expected: errorExec, |
| 4661 | }, { |
| 4662 | err: context.Canceled, |
| 4663 | expected: errorCanceled, |
| 4664 | }, |
| 4665 | } |
| 4666 | |
| 4667 | for ix, c := range cases { |
| 4668 | actual := returnAPIError(c.err) |
| 4669 | require.Error(t, actual, ix) |
| 4670 | require.Equal(t, c.expected, actual.typ, ix) |
| 4671 | } |
| 4672 | } |
| 4673 | |
| 4674 | // This is a global to avoid the benchmark being optimized away. |
| 4675 | var testResponseWriter = httptest.ResponseRecorder{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…