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

@@ -5,14 +5,14 @@ import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tech/sendico/ledger/storage"
"github.com/tech/sendico/ledger/storage/model"
"github.com/tech/sendico/pkg/db/repository/builder"
"github.com/tech/sendico/pkg/db/storable"
"github.com/tech/sendico/pkg/merrors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
"go.uber.org/zap"
)
@@ -21,7 +21,7 @@ func TestBalancesStore_Get(t *testing.T) {
logger := zap.NewNop()
t.Run("Success", func(t *testing.T) {
accountRef := primitive.NewObjectID()
accountRef := bson.NewObjectID()
stub := &repositoryStub{
FindOneByFilterFunc: func(ctx context.Context, _ builder.Query, result storable.Storable) error {
balance := result.(*model.AccountBalance)
@@ -46,7 +46,7 @@ func TestBalancesStore_Get(t *testing.T) {
stub := &repositoryStub{}
store := &balancesStore{logger: logger, repo: stub}
result, err := store.Get(ctx, primitive.NilObjectID)
result, err := store.Get(ctx, bson.NilObjectID)
require.Error(t, err)
assert.Nil(t, result)
@@ -54,7 +54,7 @@ func TestBalancesStore_Get(t *testing.T) {
})
t.Run("NotFound", func(t *testing.T) {
accountRef := primitive.NewObjectID()
accountRef := bson.NewObjectID()
stub := &repositoryStub{
FindOneByFilterFunc: func(ctx context.Context, _ builder.Query, result storable.Storable) error {
return merrors.ErrNoData
@@ -70,7 +70,7 @@ func TestBalancesStore_Get(t *testing.T) {
})
t.Run("FindError", func(t *testing.T) {
accountRef := primitive.NewObjectID()
accountRef := bson.NewObjectID()
expectedErr := errors.New("database error")
stub := &repositoryStub{
FindOneByFilterFunc: func(ctx context.Context, _ builder.Query, result storable.Storable) error {
@@ -92,7 +92,7 @@ func TestBalancesStore_Upsert(t *testing.T) {
logger := zap.NewNop()
t.Run("Insert_NewBalance", func(t *testing.T) {
accountRef := primitive.NewObjectID()
accountRef := bson.NewObjectID()
var insertedBalance *model.AccountBalance
stub := &repositoryStub{
@@ -120,8 +120,8 @@ func TestBalancesStore_Upsert(t *testing.T) {
})
t.Run("Update_ExistingBalance", func(t *testing.T) {
accountRef := primitive.NewObjectID()
existingID := primitive.NewObjectID()
accountRef := bson.NewObjectID()
existingID := bson.NewObjectID()
var updatedBalance *model.AccountBalance
stub := &repositoryStub{
@@ -170,7 +170,7 @@ func TestBalancesStore_Upsert(t *testing.T) {
store := &balancesStore{logger: logger, repo: stub}
balance := &model.AccountBalance{
AccountRef: primitive.NilObjectID,
AccountRef: bson.NilObjectID,
Balance: "100.00",
}
@@ -181,7 +181,7 @@ func TestBalancesStore_Upsert(t *testing.T) {
})
t.Run("FindError", func(t *testing.T) {
accountRef := primitive.NewObjectID()
accountRef := bson.NewObjectID()
expectedErr := errors.New("database error")
stub := &repositoryStub{
@@ -203,7 +203,7 @@ func TestBalancesStore_Upsert(t *testing.T) {
})
t.Run("InsertError", func(t *testing.T) {
accountRef := primitive.NewObjectID()
accountRef := bson.NewObjectID()
expectedErr := errors.New("insert error")
stub := &repositoryStub{
@@ -228,8 +228,8 @@ func TestBalancesStore_Upsert(t *testing.T) {
})
t.Run("UpdateError", func(t *testing.T) {
accountRef := primitive.NewObjectID()
existingID := primitive.NewObjectID()
accountRef := bson.NewObjectID()
existingID := bson.NewObjectID()
expectedErr := errors.New("update error")
stub := &repositoryStub{
@@ -263,7 +263,7 @@ func TestBalancesStore_IncrementBalance(t *testing.T) {
logger := zap.NewNop()
t.Run("NotImplemented", func(t *testing.T) {
accountRef := primitive.NewObjectID()
accountRef := bson.NewObjectID()
stub := &repositoryStub{}
store := &balancesStore{logger: logger, repo: stub}
@@ -277,7 +277,7 @@ func TestBalancesStore_IncrementBalance(t *testing.T) {
stub := &repositoryStub{}
store := &balancesStore{logger: logger, repo: stub}
err := store.IncrementBalance(ctx, primitive.NilObjectID, "100.00")
err := store.IncrementBalance(ctx, bson.NilObjectID, "100.00")
require.Error(t, err)
assert.True(t, errors.Is(err, merrors.ErrInvalidArg))