Bootstrap copied BFF and local accounts with public Sendico contracts (#34)

This commit is contained in:
Stephan D committed 2026-09-12 13:37:48 +02:00
1 parent 67dc5b5b1e
commit 7062672a87
556 files changed
+42291 -777

No files matched your search

@@ -0,0 +1,54 @@
package organization
import (
"context"
"errors"
"testing"
"git.sendico.io/tech/sxchnge/bff/pkg/db/repository"
"git.sendico.io/tech/sxchnge/bff/pkg/merrors"
"go.mongodb.org/mongo-driver/v2/mongo"
)
func TestDropSupersededProvisioningIndexesIgnoresMissingIndexes(t *testing.T) {
repo := &dropIndexRepository{dropErrors: []error{
mongo.CommandError{Code: mongoIndexNotFoundCode},
mongo.CommandError{Code: mongoNamespaceNotFoundCode},
}}
if err := dropSupersededProvisioningIndexes(context.Background(), repo); err != nil {
t.Fatalf("missing superseded indexes must be ignored: %v", err)
}
if len(repo.dropped) != len(supersededProvisioningIndexes) {
t.Fatalf("drop count mismatch: got=%d want=%d", len(repo.dropped), len(supersededProvisioningIndexes))
}
}
func TestDropSupersededProvisioningIndexesPreservesUnexpectedFailure(t *testing.T) {
wantErr := merrors.ServiceUnavailable("MongoDB is unavailable")
repo := &dropIndexRepository{dropErrors: []error{wantErr}}
err := dropSupersededProvisioningIndexes(context.Background(), repo)
if !errors.Is(err, wantErr) {
t.Fatalf("unexpected drop failure must be preserved: got=%v want=%v", err, wantErr)
}
if len(repo.dropped) != 1 {
t.Fatalf("cleanup must stop after an unexpected failure: dropped=%v", repo.dropped)
}
}
type dropIndexRepository struct {
repository.Repository
dropErrors []error
dropped []string
}
func (r *dropIndexRepository) DropIndex(_ context.Context, name string) error {
r.dropped = append(r.dropped, name)
if len(r.dropErrors) == 0 {
return nil
}
err := r.dropErrors[0]
r.dropErrors = r.dropErrors[1:]
return err
}