fixed tests and compilation

This commit is contained in:
Stephan D
2026-02-13 02:33:22 +01:00
parent 71a7a474c8
commit 1b3aa0f9ea
8 changed files with 27 additions and 73 deletions

View File

@@ -200,7 +200,7 @@ type repositoryStub struct {
func (r *repositoryStub) Ping(context.Context) error { return nil }
func (r *repositoryStub) Rates() storage.RatesStore { return r.rates }
func (r *repositoryStub) Quotes() quotestorage.QuotesStore { return nil }
func (r *repositoryStub) Quotes() storage.QuotesStore { return nil }
func (r *repositoryStub) Pairs() storage.PairStore { return nil }
func (r *repositoryStub) Currencies() storage.CurrencyStore { return nil }

View File

@@ -19,16 +19,16 @@ import (
type repositoryStub struct {
rates storage.RatesStore
quotes quotestorage.QuotesStore
quotes storage.QuotesStore
pairs storage.PairStore
currencies storage.CurrencyStore
pingErr error
}
func (r *repositoryStub) Ping(ctx context.Context) error { return r.pingErr }
func (r *repositoryStub) Rates() storage.RatesStore { return r.rates }
func (r *repositoryStub) Quotes() quotestorage.QuotesStore { return r.quotes }
func (r *repositoryStub) Pairs() storage.PairStore { return r.pairs }
func (r *repositoryStub) Ping(ctx context.Context) error { return r.pingErr }
func (r *repositoryStub) Rates() storage.RatesStore { return r.rates }
func (r *repositoryStub) Quotes() storage.QuotesStore { return r.quotes }
func (r *repositoryStub) Pairs() storage.PairStore { return r.pairs }
func (r *repositoryStub) Currencies() storage.CurrencyStore {
return r.currencies
}

View File

@@ -21,7 +21,7 @@ type Store struct {
txFactory transaction.Factory
rates storage.RatesStore
quotes quotestorage.QuotesStore
quotes storage.QuotesStore
pairs storage.PairStore
currencies storage.CurrencyStore
}
@@ -92,7 +92,7 @@ func (s *Store) Rates() storage.RatesStore {
return s.rates
}
func (s *Store) Quotes() quotestorage.QuotesStore {
func (s *Store) Quotes() storage.QuotesStore {
return s.quotes
}

View File

@@ -23,7 +23,7 @@ type quotesStore struct {
txFactory transaction.Factory
}
func NewQuotes(logger mlogger.Logger, db *mongo.Database, txFactory transaction.Factory) (quotestorage.QuotesStore, error) {
func NewQuotes(logger mlogger.Logger, db *mongo.Database, txFactory transaction.Factory) (storage.QuotesStore, error) {
repo := repository.CreateMongoRepository(db, model.QuotesCollection)
indexes := []*ri.Definition{
{

View File

@@ -22,6 +22,7 @@ type repoStub struct {
findOneFn func(ctx context.Context, query builder.Query, result storable.Storable) error
findManyFn func(ctx context.Context, query builder.Query, decoder rd.DecodingFunc) error
updateFn func(ctx context.Context, obj storable.Storable) error
upsertFn func(ctx context.Context, obj storable.Storable) error
patchManyFn func(ctx context.Context, filter builder.Query, patch builder.Patch) (int, error)
createIdxFn func(def *ri.Definition) error
}
@@ -69,6 +70,13 @@ func (r *repoStub) Update(ctx context.Context, obj storable.Storable) error {
return nil
}
func (r *repoStub) Upsert(ctx context.Context, obj storable.Storable) error {
if r.upsertFn != nil {
return r.upsertFn(ctx, obj)
}
return nil
}
func (r *repoStub) Patch(ctx context.Context, id bson.ObjectID, patch builder.Patch) error {
return merrors.NotImplemented("Patch not used")
}

View File

@@ -19,6 +19,7 @@ type repositoryStub struct {
InsertFunc func(ctx context.Context, object storable.Storable, filter builder.Query) error
InsertManyFunc func(ctx context.Context, objects []storable.Storable) error
UpdateFunc func(ctx context.Context, object storable.Storable) error
UpsertFunc func(ctx context.Context, object storable.Storable) error
DeleteFunc func(ctx context.Context, id bson.ObjectID) error
FindOneByFilterFunc func(ctx context.Context, filter builder.Query, result storable.Storable) error
FindManyByFilterFunc func(ctx context.Context, filter builder.Query, decoder rd.DecodingFunc) error
@@ -64,6 +65,13 @@ func (r *repositoryStub) Update(ctx context.Context, object storable.Storable) e
return nil
}
func (r *repositoryStub) Upsert(ctx context.Context, object storable.Storable) error {
if r.UpsertFunc != nil {
return r.UpsertFunc(ctx, object)
}
return nil
}
func (r *repositoryStub) Delete(ctx context.Context, id bson.ObjectID) error {
if r.DeleteFunc != nil {
return r.DeleteFunc(ctx, id)

View File

@@ -11,7 +11,7 @@ import (
"github.com/tech/sendico/pkg/mlogger"
"github.com/tech/sendico/pkg/model"
"github.com/tech/sendico/pkg/mservice"
methodsv1 "github.com/tech/sendico/pkg/proto/payments/methods/v1"
paginationv2 "github.com/tech/sendico/pkg/proto/common/pagination/v2"
"go.mongodb.org/mongo-driver/v2/bson"
)
@@ -53,7 +53,7 @@ func encodePaymentMethod(pm *model.PaymentMethod) ([]byte, error) {
return payload, nil
}
func toModelCursor(cursor *methodsv1.ViewCursor) *model.ViewCursor {
func toModelCursor(cursor *paginationv2.ViewCursor) *model.ViewCursor {
if cursor == nil {
return nil
}

View File

@@ -2,7 +2,6 @@ package orchestrator
import (
"context"
"strings"
"testing"
mntxclient "github.com/tech/sendico/gateway/mntx/client"
@@ -216,64 +215,3 @@ func TestExecutePaymentPlan_SourceBeforeDestination(t *testing.T) {
}
}
func TestExecutePaymentPlan_RejectsLegacyLedgerOperations(t *testing.T) {
ctx := context.Background()
store := newStubPaymentsStore()
repo := &stubRepository{store: store}
ledgerFake := &ledgerclient.Fake{}
svc := &Service{
logger: zap.NewNop(),
storage: repo,
deps: serviceDependencies{
ledger: ledgerDependency{
client: ledgerFake,
internal: ledgerFake,
},
},
}
executor := newPaymentExecutor(&svc.deps, svc.logger, svc)
payment := &model.Payment{
PaymentRef: "pay-legacy-1",
IdempotencyKey: "pay-legacy-1",
OrganizationBoundBase: mo.OrganizationBoundBase{
OrganizationRef: bson.NewObjectID(),
},
Intent: model.PaymentIntent{
Ref: "ref-legacy-1",
Kind: model.PaymentKindPayout,
Source: model.PaymentEndpoint{
Type: model.EndpointTypeManagedWallet,
ManagedWallet: &model.ManagedWalletEndpoint{
ManagedWalletRef: "wallet-src",
},
},
Destination: model.PaymentEndpoint{
Type: model.EndpointTypeCard,
Card: &model.CardEndpoint{MaskedPan: "4111"},
},
},
PaymentPlan: &model.PaymentPlan{
ID: "pay-legacy-1",
IdempotencyKey: "pay-legacy-1",
Steps: []*model.PaymentStep{
{StepID: "ledger_block", Rail: model.RailLedger, Action: model.RailOperationBlock, Amount: &paymenttypes.Money{Currency: "USD", Amount: "100"}},
},
},
}
store.payments[payment.PaymentRef] = payment
err := executor.executePaymentPlan(ctx, store, payment, &sharedv1.PaymentQuote{})
if err == nil {
t.Fatal("expected legacy ledger operation error")
}
if !strings.Contains(err.Error(), "unsupported action") {
t.Fatalf("unexpected error: %v", err)
}
}