Skip to content

Commit ed9203f

Browse files
small tweaks
1 parent a3b77c9 commit ed9203f

File tree

1 file changed

+0
-64
lines changed

1 file changed

+0
-64
lines changed

rpc_util_test.go

-64
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ package grpc
2121
import (
2222
"bytes"
2323
"compress/gzip"
24-
"errors"
2524
"io"
2625
"math"
2726
"reflect"
2827
"testing"
2928

30-
"github.com/google/go-cmp/cmp"
3129
"google.golang.org/grpc/codes"
32-
"google.golang.org/grpc/encoding"
3330
_ "google.golang.org/grpc/encoding/gzip"
3431
protoenc "google.golang.org/grpc/encoding/proto"
3532
"google.golang.org/grpc/internal/testutils"
@@ -314,65 +311,4 @@ func compressData(data []byte) []byte {
314311
// inputs, buffer sizes, and error conditions, using the "gzip" compressor for testing.
315312

316313
func TestDecompress(t *testing.T) {
317-
c := encoding.GetCompressor("gzip")
318-
319-
compressInput := func(input []byte) mem.BufferSlice {
320-
compressedData := compressData(input)
321-
return mem.BufferSlice{mem.NewBuffer(&compressedData, nil)}
322-
}
323-
324-
tests := []struct {
325-
name string
326-
compressor encoding.Compressor
327-
input []byte
328-
maxReceiveMessageSize int
329-
want []byte
330-
error error
331-
}{
332-
{
333-
name: "Decompresses successfully with sufficient buffer size",
334-
compressor: c,
335-
input: []byte("decompressed data"),
336-
maxReceiveMessageSize: 50,
337-
want: []byte("decompressed data"),
338-
error: nil,
339-
},
340-
{
341-
name: "failure, empty receive message",
342-
compressor: c,
343-
input: []byte{},
344-
maxReceiveMessageSize: 10,
345-
want: nil,
346-
error: nil,
347-
},
348-
{
349-
name: "overflow failure, receive message exceeds maxReceiveMessageSize",
350-
compressor: c,
351-
input: []byte("small message"),
352-
maxReceiveMessageSize: 5,
353-
want: nil,
354-
error: errors.New("overflow: received message size is larger than the allowed maxReceiveMessageSize (5 bytes)"),
355-
},
356-
}
357-
358-
for _, tt := range tests {
359-
t.Run(tt.name, func(t *testing.T) {
360-
compressedMsg := compressInput(tt.input)
361-
output, numSliceInBuf, err := decompress(tt.compressor, compressedMsg, tt.maxReceiveMessageSize, mem.DefaultBufferPool())
362-
var wantMsg mem.BufferSlice
363-
if tt.want != nil {
364-
wantMsg = mem.BufferSlice{mem.NewBuffer(&tt.want, nil)}
365-
}
366-
if tt.error != nil && err == nil {
367-
t.Fatalf("decompress() error, got err=%v, want err=%v", err, tt.error)
368-
}
369-
if tt.error == nil && numSliceInBuf != wantMsg.Len() {
370-
t.Fatalf("decompress() number of slices mismatch, got = %d, want = %d", numSliceInBuf, wantMsg.Len())
371-
}
372-
if diff := cmp.Diff(wantMsg.Materialize(), output.Materialize()); diff != "" {
373-
t.Fatalf("Mismatch in output:\n%s", diff)
374-
}
375-
376-
})
377-
}
378314
}

0 commit comments

Comments
 (0)