Skip to content

Commit

Permalink
ProxyRecorder struct with inheritance to httptest.ResponseRecorder, P…
Browse files Browse the repository at this point in the history
…roxyRecorder adds CloseNotify receiver function from http.CloseNotifier which is needed for testing the oci proxy route and missing from httptest.ResponseRecorder

Signed-off-by: Michael Valdron <mvaldron@redhat.com>
  • Loading branch information
michael-valdron committed Jul 29, 2022
1 parent 52d94f6 commit 7163dfb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions index/server/pkg/ocitest/ocitest.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,18 @@ func (server *MockOCIServer) Start(listenAddr string) error {
func (server *MockOCIServer) Close() {
server.httpserver.Close()
}

type ProxyRecorder struct {
*httptest.ResponseRecorder
http.CloseNotifier
}

func NewProxyRecorder() *ProxyRecorder {
return &ProxyRecorder{
ResponseRecorder: httptest.NewRecorder(),
}
}

func (rec *ProxyRecorder) CloseNotify() <-chan bool {
return make(<-chan bool)
}

0 comments on commit 7163dfb

Please sign in to comment.