Skip to content

Commit

Permalink
Revert "Don't use gzip name"
Browse files Browse the repository at this point in the history
This reverts commit 63320aa.
  • Loading branch information
arjan-bal committed Dec 23, 2024
1 parent 63320aa commit 1bf3afa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/compressor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,9 @@ func (f *fakeCompressor) Decompress(io.Reader) (io.Reader, error) {
}

func (f *fakeCompressor) Name() string {
return "fake-gzip"
// Use the name of an existing compressor to avoid interactions with other
// tests since compressors can't be un-registered.
return "gzip"
}

type nopWriteCloser struct {
Expand All @@ -817,6 +819,10 @@ func (nopWriteCloser) Close() error {
// max receive message size restricted to 99 bytes. The test verifies that the
// client receives a ResourceExhausted response from the server.
func (s) TestDecompressionExceedsMaxMessageSize(t *testing.T) {
oldC := encoding.GetCompressor("gzip")
defer func() {
encoding.RegisterCompressor(oldC)
}()
const messageLen = 100
encoding.RegisterCompressor(&fakeCompressor{decompressedMessageSize: messageLen})
ss := &stubserver.StubServer{
Expand All @@ -833,7 +839,7 @@ func (s) TestDecompressionExceedsMaxMessageSize(t *testing.T) {
defer cancel()

req := &testpb.SimpleRequest{Payload: &testpb.Payload{}}
_, err := ss.Client.UnaryCall(ctx, req, grpc.UseCompressor("fake-gzip"))
_, err := ss.Client.UnaryCall(ctx, req, grpc.UseCompressor("gzip"))
if got, want := status.Code(err), codes.ResourceExhausted; got != want {
t.Errorf("Client.UnaryCall(%+v) returned status %v, want %v", req, got, want)
}
Expand Down

0 comments on commit 1bf3afa

Please sign in to comment.