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,51 @@
package organization
import (
"context"
"errors"
"testing"
"git.sendico.io/tech/sxchnge/bff/pkg/merrors"
"git.sendico.io/tech/sxchnge/bff/pkg/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/v2/bson"
)
func TestOrganizationDB_SetArchived_TogglesState(t *testing.T) {
ctx := context.Background()
accountRef := bson.NewObjectID()
orgDB := newTestOrganizationDB(t)
org := &model.Organization{
OrganizationBase: model.OrganizationBase{
Describable: model.Describable{Name: "Sendico"},
TimeZone: "UTC",
},
}
org.SetID(bson.NewObjectID())
require.NoError(t, orgDB.Create(ctx, accountRef, *org.GetID(), org))
var stored model.Organization
require.NoError(t, orgDB.Get(ctx, accountRef, *org.GetID(), &stored))
assert.False(t, stored.IsArchived())
require.NoError(t, orgDB.SetArchived(ctx, accountRef, *org.GetID(), true, false))
require.NoError(t, orgDB.Get(ctx, accountRef, *org.GetID(), &stored))
assert.True(t, stored.IsArchived())
require.NoError(t, orgDB.SetArchived(ctx, accountRef, *org.GetID(), false, false))
require.NoError(t, orgDB.Get(ctx, accountRef, *org.GetID(), &stored))
assert.False(t, stored.IsArchived())
}
func TestOrganizationDB_SetArchived_UnknownOrganization(t *testing.T) {
ctx := context.Background()
accountRef := bson.NewObjectID()
orgDB := newTestOrganizationDB(t)
err := orgDB.SetArchived(ctx, accountRef, bson.NewObjectID(), true, false)
require.Error(t, err)
assert.True(t, errors.Is(err, merrors.ErrNoData))
}