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

@@ -3,23 +3,23 @@ package accountserviceimp
import (
"testing"
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson/primitive"
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/model"
"go.mongodb.org/mongo-driver/v2/bson"
)
func TestDeleteAccount_Validation(t *testing.T) {
t.Run("DeleteAccount_LastMemberFails", func(t *testing.T) {
orgID := primitive.NewObjectID()
accountID := primitive.NewObjectID()
orgID := bson.NewObjectID()
accountID := bson.NewObjectID()
org := &model.Organization{
OrganizationBase: model.OrganizationBase{
Describable: model.Describable{Name: "Single Member Org"},
},
Members: []primitive.ObjectID{accountID}, // Only one member
Members: []bson.ObjectID{accountID}, // Only one member
}
org.ID = orgID
@@ -30,15 +30,15 @@ func TestDeleteAccount_Validation(t *testing.T) {
})
t.Run("DeleteAccount_MultipleMembersSuccess", func(t *testing.T) {
orgID := primitive.NewObjectID()
accountID := primitive.NewObjectID()
otherAccountID := primitive.NewObjectID()
orgID := bson.NewObjectID()
accountID := bson.NewObjectID()
otherAccountID := bson.NewObjectID()
org := &model.Organization{
OrganizationBase: model.OrganizationBase{
Describable: model.Describable{Name: "Multi Member Org"},
},
Members: []primitive.ObjectID{accountID, otherAccountID}, // Multiple members
Members: []bson.ObjectID{accountID, otherAccountID}, // Multiple members
}
org.ID = orgID
@@ -48,13 +48,13 @@ func TestDeleteAccount_Validation(t *testing.T) {
})
t.Run("DeleteAccount_EmptyMembersList", func(t *testing.T) {
orgID := primitive.NewObjectID()
orgID := bson.NewObjectID()
org := &model.Organization{
OrganizationBase: model.OrganizationBase{
Describable: model.Describable{Name: "Empty Org"},
},
Members: []primitive.ObjectID{}, // No members
Members: []bson.ObjectID{}, // No members
}
org.ID = orgID
@@ -85,7 +85,7 @@ func TestDeleteOrganization_Validation(t *testing.T) {
Describable: model.Describable{Name: "Valid Organization"},
},
}
org.ID = primitive.NewObjectID()
org.ID = bson.NewObjectID()
err := validateDeleteOrganization(org)
require.NoError(t, err)
@@ -94,7 +94,7 @@ func TestDeleteOrganization_Validation(t *testing.T) {
func TestDeleteAll_Validation(t *testing.T) {
t.Run("DeleteAll_NilOrganization", func(t *testing.T) {
accountID := primitive.NewObjectID()
accountID := bson.NewObjectID()
err := validateDeleteAll(nil, accountID)
require.Error(t, err)
assert.Contains(t, err.Error(), "organization cannot be nil")
@@ -106,9 +106,9 @@ func TestDeleteAll_Validation(t *testing.T) {
Describable: model.Describable{Name: "Valid Organization"},
},
}
org.ID = primitive.NewObjectID()
org.ID = bson.NewObjectID()
err := validateDeleteAll(org, primitive.NilObjectID)
err := validateDeleteAll(org, bson.NilObjectID)
require.Error(t, err)
assert.Contains(t, err.Error(), "account ID cannot be empty")
})
@@ -119,8 +119,8 @@ func TestDeleteAll_Validation(t *testing.T) {
Describable: model.Describable{Name: "Valid Organization"},
},
}
org.ID = primitive.NewObjectID()
accountID := primitive.NewObjectID()
org.ID = bson.NewObjectID()
accountID := bson.NewObjectID()
err := validateDeleteAll(org, accountID)
require.NoError(t, err)
@@ -139,17 +139,17 @@ func validateDeleteOrganization(org *model.Organization) error {
if org == nil {
return merrors.InvalidArgument("organization cannot be nil")
}
if org.ID == primitive.NilObjectID {
if org.ID == bson.NilObjectID {
return merrors.InvalidArgument("organization ID cannot be empty")
}
return nil
}
func validateDeleteAll(org *model.Organization, accountRef primitive.ObjectID) error {
func validateDeleteAll(org *model.Organization, accountRef bson.ObjectID) error {
if org == nil {
return merrors.InvalidArgument("organization cannot be nil")
}
if accountRef == primitive.NilObjectID {
if accountRef == bson.NilObjectID {
return merrors.InvalidArgument("account ID cannot be empty")
}
return nil