linting
This commit is contained in:
@@ -35,8 +35,8 @@ func TestCurrencyStoreGet(t *testing.T) {
|
||||
|
||||
func TestCurrencyStoreList(t *testing.T) {
|
||||
repo := &repoStub{
|
||||
findManyFn: func(_ context.Context, _ builder.Query, decode rd.DecodingFunc) error {
|
||||
return runDecoderWithDocs(t, decode, &model.Currency{Code: "USD"})
|
||||
findManyFn: func(ctx context.Context, _ builder.Query, decode rd.DecodingFunc) error {
|
||||
return runDecoderWithDocs(ctx, t, decode, &model.Currency{Code: "USD"})
|
||||
},
|
||||
}
|
||||
store := ¤cyStore{logger: zap.NewNop(), repo: repo}
|
||||
|
||||
@@ -16,11 +16,11 @@ import (
|
||||
|
||||
func TestPairStoreListEnabled(t *testing.T) {
|
||||
repo := &repoStub{
|
||||
findManyFn: func(_ context.Context, _ builder.Query, decode rd.DecodingFunc) error {
|
||||
findManyFn: func(ctx context.Context, _ builder.Query, decode rd.DecodingFunc) error {
|
||||
docs := []interface{}{
|
||||
&model.Pair{Pair: model.CurrencyPair{Base: "USD", Quote: "EUR"}},
|
||||
}
|
||||
return runDecoderWithDocs(t, decode, docs...)
|
||||
return runDecoderWithDocs(ctx, t, decode, docs...)
|
||||
},
|
||||
}
|
||||
store := &pairStore{logger: zap.NewNop(), repo: repo}
|
||||
|
||||
@@ -70,9 +70,9 @@ func TestRatesStoreUpsertUpdate(t *testing.T) {
|
||||
func TestRatesStoreLatestSnapshot(t *testing.T) {
|
||||
now := time.Now().UnixMilli()
|
||||
repo := &repoStub{
|
||||
findManyFn: func(_ context.Context, _ builder.Query, decode rd.DecodingFunc) error {
|
||||
findManyFn: func(ctx context.Context, _ builder.Query, decode rd.DecodingFunc) error {
|
||||
doc := &model.RateSnapshot{RateRef: "latest", AsOfUnixMs: now}
|
||||
return runDecoderWithDocs(t, decode, doc)
|
||||
return runDecoderWithDocs(ctx, t, decode, doc)
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -176,16 +176,18 @@ func cloneCurrency(t *testing.T, obj storable.Storable) *model.Currency {
|
||||
return ©
|
||||
}
|
||||
|
||||
func runDecoderWithDocs(t *testing.T, decode rd.DecodingFunc, docs ...interface{}) error {
|
||||
func runDecoderWithDocs(ctx context.Context, t *testing.T, decode rd.DecodingFunc, docs ...interface{}) error {
|
||||
t.Helper()
|
||||
cur, err := mongo.NewCursorFromDocuments(docs, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create cursor: %v", err)
|
||||
}
|
||||
defer cur.Close(context.Background())
|
||||
defer func() {
|
||||
_ = cur.Close(ctx)
|
||||
}()
|
||||
|
||||
if len(docs) > 0 {
|
||||
if !cur.Next(context.Background()) {
|
||||
if !cur.Next(ctx) {
|
||||
return cur.Err()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user