Skip to content

Commit 733d9ab

Browse files
authored
[chore] [receiver/webhookevent] Fix Good request with gzip test in webhookeventreceiver (open-telemetry#43874)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This test ostensibly tests that a request sent with gzip is accepted by the receiver, however because there's no mechanism to return back from the receiver what log was actually parsed, it was missed that this doesn't actually excercise the gzip flow. In particular the test: - Doesn't close the writer, which can result in invalid gzip streams - Doesn't set the Content-Encoding on the request, so the receiver never realises it's meant to use gzip anyway As a result, this test was passing, but the "log" produced was a meaningless truncated gzip stream. This fixes the test to actually exercise the flow (which, thankfully, is working). Signed-off-by: sinkingpoint <[email protected]>
1 parent 8342f30 commit 733d9ab

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

receiver/webhookeventreceiver/receiver_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,11 @@ func TestHandleReq(t *testing.T) {
180180
gzipWriter := gzip.NewWriter(&msg)
181181
_, err = gzipWriter.Write(msgJSON)
182182
require.NoError(t, err, "Gzip writer failed")
183+
err = gzipWriter.Close()
184+
require.NoError(t, err, "Gzip writer failed to close")
183185

184186
req := httptest.NewRequest(http.MethodPost, "http://localhost/events", &msg)
187+
req.Header.Set("Content-Encoding", "gzip")
185188
return req
186189
}(),
187190
},

0 commit comments

Comments
 (0)