Skip to content

Commit

Permalink
changes done for file when want is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
misvivek committed Nov 28, 2024
1 parent 63934e6 commit f3afb78
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rpc_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,15 @@ func TestDecompress(t *testing.T) {
compressor: c,
input: []byte(""),
maxReceiveMessageSize: 10,
want: []byte(""),
want: nil,
error: nil,
},
{
name: "overflow failure, receive message exceeds maxReceiveMessageSize",
compressor: c,
input: []byte("small message"),
maxReceiveMessageSize: 5,
want: []byte("smalll"),
want: nil,
error: errors.New("overflow: received message size is larger than the allowed maxReceiveMessageSize (5 bytes)"),
},
}
Expand All @@ -356,16 +356,20 @@ func TestDecompress(t *testing.T) {
return mem.BufferSlice{mem.NewBuffer(&compressedData, nil)}
}()
output, _, err := decompress(tt.compressor, compressedMsg, tt.maxReceiveMessageSize, nil)
wantMsg := mem.BufferSlice{mem.NewBuffer(&tt.want, nil)}
var wantMsg mem.BufferSlice
if tt.want != nil {
wantMsg = mem.BufferSlice{mem.NewBuffer(&tt.want, nil)}
}
if tt.error != nil && err == nil {
t.Fatalf("decompress() error, got err=%v, want err=%v", err, tt.error)
}
if wantMsg != nil && output == nil {
t.Fatalf("decompress() got = nil, want = non nil")
}
if diff := cmp.Diff(wantMsg, output); diff != "" {
t.Fatalf("decompress() mismatch in bytes (-want +got):\n%s", diff)
t.Fatalf("Mismatch in output:\n%s", diff)
}

})
}
}

0 comments on commit f3afb78

Please sign in to comment.