Skip to content

Commit

Permalink
core/services/ocr/plugins/llo: fix onchain cache test race
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Aug 26, 2024
1 parent 3257b8f commit b9ac612
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (h *mockHTTPClient) SetResponse(resp *http.Response, err error) {

type MockReadCloser struct {
data []byte
mu sync.RWMutex
reader *bytes.Reader
}

Expand All @@ -70,11 +71,15 @@ func NewMockReadCloser(data []byte) *MockReadCloser {

// Read reads from the underlying data
func (m *MockReadCloser) Read(p []byte) (int, error) {
m.mu.RLock()
defer m.mu.RUnlock()
return m.reader.Read(p)
}

// Close resets the reader to the beginning of the data
func (m *MockReadCloser) Close() error {
m.mu.Lock()
defer m.mu.Unlock()
m.reader.Seek(0, io.SeekStart)
return nil
}
Expand Down

0 comments on commit b9ac612

Please sign in to comment.