case audio <- audioChunk[:n]. Вроде с другой стороны в mock все ждут.
func (h *Handler) processBackendResponses(ctx context.Context, w http.ResponseWriter, responsesCh <-chan *denoiser.Response,
) error {
var (
resp *denoiser.Response
ok bool
firstBytesSent bool
)
flusher, _ := w.(http.Flusher)
for {
select {
case <-ctx.Done():
return ctx.Err()
case resp, ok = <-responsesCh:
if !ok {
// h.logger.Info(ctx, "Finished request successfully")
// h.metrics.SuccessfulRequests.With(h.metricLabels).Inc()
return nil
}
if resp.Err != nil {
return resp.Err
}
if resp.Audio != nil {
if !firstBytesSent {
firstBytesSent = true
w.Header().Set(headerContentType, contentTypeWAV)
}
if err := contextutil.DoWithTimeout(ctx, func() error {
_, err := w.Write(resp.Audio)
return err
}, h.cfg.WriteTimeout.ToNative()); err != nil {
h.logger.Warne(ctx, "Could not write response", err)
h.metrics.InternalErrors.With(h.metricLabels).Inc()
return err
}
flusher.Flush()
}
}
}
}
func (_m *mockDenoiser) Denoise(ctx context.Context, request *denoiser.Request, reqData <-chan []byte) <-chan *denoiser.Response {
ret := _m.Called(ctx, request, reqData)
var r0 <-chan *denoiser.Response
if rf, ok := ret.Get(0).(func(context.Context, *denoiser.Request, <-chan []byte) <-chan *denoiser.Response); ok {
r0 = rf(ctx, request, reqData)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(<-chan *denoiser.Response)
}
}
return r0
}