This commit is contained in:
Stephan D
2026-03-10 12:31:09 +01:00
parent d87e709f43
commit e77d1ab793
287 changed files with 2089 additions and 1550 deletions

View File

@@ -0,0 +1,47 @@
version: "2"
linters:
default: none
enable:
- bodyclose
- canonicalheader
- copyloopvar
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- gosec
- govet
- ineffassign
- nilerr
- nilnesserr
- nilnil
- noctx
- rowserrcheck
- sqlclosecheck
- staticcheck
- unconvert
- wastedassign
disable:
- depguard
- exhaustruct
- gochecknoglobals
- gochecknoinits
- gomoddirectives
- wrapcheck
- cyclop
- dupl
- funlen
- gocognit
- gocyclo
- ireturn
- lll
- mnd
- nestif
- nlreturn
- noinlineerr
- paralleltest
- tagliatelle
- testpackage
- varnamelen
- wsl_v5

View File

@@ -47,13 +47,13 @@ func (q *Quote) MarkConsumed(ledgerTxnRef string, consumedAt time.Time) {
q.ConsumedByLedgerTxnRef = ledgerTxnRef
ts := consumedAt.UnixMilli()
q.ConsumedAtUnixMs = &ts
q.Base.Update()
q.Update()
}
// MarkExpired marks the quote as expired.
func (q *Quote) MarkExpired() {
q.Status = QuoteStatusExpired
q.Base.Update()
q.Update()
}
// IsExpired reports whether the quote has passed its expiration instant.

View File

@@ -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 := &currencyStore{logger: zap.NewNop(), repo: repo}

View File

@@ -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}

View File

@@ -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)
},
}

View File

@@ -176,16 +176,18 @@ func cloneCurrency(t *testing.T, obj storable.Storable) *model.Currency {
return &copy
}
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()
}
}