fixed doc env vars + mongo v2 migration

This commit is contained in:
Stephan D
2026-01-31 00:26:42 +01:00
parent cbb7bd8ba6
commit 1aa7e287fb
356 changed files with 1705 additions and 1729 deletions

View File

@@ -6,7 +6,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
"go.uber.org/zap"
"github.com/tech/sendico/ledger/storage"
@@ -45,7 +45,7 @@ func (s *accountStoreStub) Create(_ context.Context, account *pmodel.LedgerAccou
}
if account.GetID() == nil || account.GetID().IsZero() {
account.SetID(primitive.NewObjectID())
account.SetID(bson.NewObjectID())
}
account.CreatedAt = account.CreatedAt.UTC()
@@ -55,18 +55,18 @@ func (s *accountStoreStub) Create(_ context.Context, account *pmodel.LedgerAccou
return nil
}
func (s *accountStoreStub) GetByAccountCode(_ context.Context, _ primitive.ObjectID, _ string, _ string) (*pmodel.LedgerAccount, error) {
func (s *accountStoreStub) GetByAccountCode(_ context.Context, _ bson.ObjectID, _ string, _ string) (*pmodel.LedgerAccount, error) {
if s.existingErr != nil {
return nil, s.existingErr
}
return s.existing, nil
}
func (s *accountStoreStub) Get(context.Context, primitive.ObjectID) (*pmodel.LedgerAccount, error) {
func (s *accountStoreStub) Get(context.Context, bson.ObjectID) (*pmodel.LedgerAccount, error) {
return nil, storage.ErrAccountNotFound
}
func (s *accountStoreStub) GetByRole(_ context.Context, orgRef primitive.ObjectID, currency string, role pmodel.AccountRole) (*pmodel.LedgerAccount, error) {
func (s *accountStoreStub) GetByRole(_ context.Context, orgRef bson.ObjectID, currency string, role pmodel.AccountRole) (*pmodel.LedgerAccount, error) {
if s.existingByRole != nil {
if acc, ok := s.existingByRole[role]; ok {
return acc, nil
@@ -84,7 +84,7 @@ func (s *accountStoreStub) GetSystemAccount(context.Context, pmodel.SystemAccoun
return nil, storage.ErrAccountNotFound
}
func (s *accountStoreStub) GetDefaultSettlement(context.Context, primitive.ObjectID, string) (*pmodel.LedgerAccount, error) {
func (s *accountStoreStub) GetDefaultSettlement(context.Context, bson.ObjectID, string) (*pmodel.LedgerAccount, error) {
if s.defaultErr != nil {
return nil, s.defaultErr
}
@@ -94,11 +94,11 @@ func (s *accountStoreStub) GetDefaultSettlement(context.Context, primitive.Objec
return nil, storage.ErrAccountNotFound
}
func (s *accountStoreStub) ListByOrganization(context.Context, primitive.ObjectID, *storage.AccountsFilter, int, int) ([]*pmodel.LedgerAccount, error) {
func (s *accountStoreStub) ListByOrganization(context.Context, bson.ObjectID, *storage.AccountsFilter, int, int) ([]*pmodel.LedgerAccount, error) {
return nil, nil
}
func (s *accountStoreStub) UpdateStatus(context.Context, primitive.ObjectID, pmodel.LedgerAccountStatus) error {
func (s *accountStoreStub) UpdateStatus(context.Context, bson.ObjectID, pmodel.LedgerAccountStatus) error {
return nil
}
@@ -116,7 +116,7 @@ func (r *repositoryStub) Outbox() storage.OutboxStore { return n
func TestCreateAccountResponder_Success(t *testing.T) {
t.Parallel()
orgRef := primitive.NewObjectID()
orgRef := bson.NewObjectID()
accountStore := &accountStoreStub{}
svc := &Service{
@@ -161,7 +161,7 @@ func TestCreateAccountResponder_Success(t *testing.T) {
func TestCreateAccountResponder_AutoCreatesSettlementAccount(t *testing.T) {
t.Parallel()
orgRef := primitive.NewObjectID()
orgRef := bson.NewObjectID()
accountStore := &accountStoreStub{}
svc := &Service{
@@ -237,7 +237,7 @@ func TestCreateAccountResponder_AutoCreatesSettlementAccount(t *testing.T) {
func TestCreateAccountResponder_RetriesOnConflict(t *testing.T) {
t.Parallel()
orgRef := primitive.NewObjectID()
orgRef := bson.NewObjectID()
accountStore := &accountStoreStub{
// first create attempt returns conflict, second succeeds
createErrs: []error{merrors.DataConflict("duplicate")},
@@ -292,7 +292,7 @@ func TestCreateAccountResponder_InvalidAccountType(t *testing.T) {
// AccountType missing => must fail
req := &ledgerv1.CreateAccountRequest{
OrganizationRef: primitive.NewObjectID().Hex(),
OrganizationRef: bson.NewObjectID().Hex(),
Currency: "USD",
}