From e0c7a328d26c1fa38edcaf30ad1bcce9395bf300 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Fri, 4 Jul 2025 14:09:09 +0100 Subject: [PATCH] test: add `BinaryResponse` helper function Signed-off-by: Babak K. Shandiz --- pkg/httpmock/stub.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/httpmock/stub.go b/pkg/httpmock/stub.go index 3b03ae718..f15423c84 100644 --- a/pkg/httpmock/stub.go +++ b/pkg/httpmock/stub.go @@ -127,6 +127,12 @@ func StringResponse(body string) Responder { } } +func BinaryResponse(body []byte) Responder { + return func(req *http.Request) (*http.Response, error) { + return httpResponse(200, req, bytes.NewBuffer(body)), nil + } +} + func WithHost(matcher Matcher, host string) Matcher { return func(req *http.Request) bool { if !strings.EqualFold(req.Host, host) {