handle context cancelation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package trading212
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -66,7 +67,7 @@ const (
|
||||
LimitSell = "limit sell"
|
||||
)
|
||||
|
||||
func (rr RecordReader) ReadRecord() (internal.Record, error) {
|
||||
func (rr RecordReader) ReadRecord(_ context.Context) (internal.Record, error) {
|
||||
for {
|
||||
raw, err := rr.reader.Read()
|
||||
if err != nil {
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestRecordReader_ReadRecord(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
rr := NewRecordReader(tt.r)
|
||||
got, gotErr := rr.ReadRecord()
|
||||
got, gotErr := rr.ReadRecord(t.Context())
|
||||
if gotErr != nil {
|
||||
if !tt.wantErr {
|
||||
t.Fatalf("ReadRecord() failed: %v", gotErr)
|
||||
|
||||
Reference in New Issue
Block a user