mirror of https://github.com/grafana/loki
Use correct error write function (#11487)
**What this PR does / why we need it**: This fixes the last known regression for `protobuf` encoding. **Checklist** - [ ] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [ ] Documentation added - [x] Tests updated - [ ] `CHANGELOG.md` updated - [ ] If the change is worth mentioning in the release notes, add `add-to-release-notes` label - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/setup/upgrade/_index.md` - [ ] For Helm chart changes bump the Helm chart version in `production/helm/loki/Chart.yaml` and update `production/helm/loki/CHANGELOG.md` and `production/helm/loki/README.md`. [Example PR](pull/11477/head^2d10549e3ec
) - [ ] If the change is deprecating or removing a configuration option, update the `deprecated-config.yaml` and `deleted-config.yaml` files respectively in the `tools/deprecated-config-checker` directory. [Example PR](0d4416a4b0
)
parent
60340639cc
commit
8822ae660d
@ -1,30 +0,0 @@ |
||||
package transport |
||||
|
||||
import ( |
||||
"context" |
||||
"net/http" |
||||
"net/http/httptest" |
||||
"testing" |
||||
|
||||
"github.com/grafana/dskit/httpgrpc" |
||||
"github.com/pkg/errors" |
||||
"github.com/stretchr/testify/require" |
||||
) |
||||
|
||||
func TestWriteError(t *testing.T) { |
||||
for _, test := range []struct { |
||||
status int |
||||
err error |
||||
}{ |
||||
{http.StatusInternalServerError, errors.New("unknown")}, |
||||
{http.StatusGatewayTimeout, context.DeadlineExceeded}, |
||||
{StatusClientClosedRequest, context.Canceled}, |
||||
{http.StatusBadRequest, httpgrpc.Errorf(http.StatusBadRequest, "")}, |
||||
} { |
||||
t.Run(test.err.Error(), func(t *testing.T) { |
||||
w := httptest.NewRecorder() |
||||
writeError(w, test.err) |
||||
require.Equal(t, test.status, w.Result().StatusCode) |
||||
}) |
||||
} |
||||
} |
Loading…
Reference in new issue