2025-04-29 06:03:47 +02:00
|
|
|
package domain_test
|
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// import (
|
|
|
|
// "context"
|
|
|
|
// "log/slog"
|
|
|
|
// "testing"
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// "github.com/stretchr/testify/assert"
|
|
|
|
// "github.com/stretchr/testify/require"
|
|
|
|
// "go.opentelemetry.io/otel"
|
|
|
|
// "go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
|
|
|
|
// sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
|
|
|
// "go.uber.org/mock/gomock"
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// . "github.com/zitadel/zitadel/backend/v3/domain"
|
|
|
|
// "github.com/zitadel/zitadel/backend/v3/storage/database/dbmock"
|
|
|
|
// "github.com/zitadel/zitadel/backend/v3/storage/database/repository"
|
|
|
|
// "github.com/zitadel/zitadel/backend/v3/telemetry/logging"
|
|
|
|
// "github.com/zitadel/zitadel/backend/v3/telemetry/tracing"
|
|
|
|
// )
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-05-08 19:01:55 +02:00
|
|
|
// These tests give an overview of how to use the domain package.
|
2025-06-13 17:05:37 +02:00
|
|
|
// func TestExample(t *testing.T) {
|
|
|
|
// t.Skip("skip example test because it is not a real test")
|
|
|
|
// ctx := context.Background()
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// ctrl := gomock.NewController(t)
|
|
|
|
// pool := dbmock.NewMockPool(ctrl)
|
|
|
|
// tx := dbmock.NewMockTransaction(ctrl)
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// pool.EXPECT().Begin(gomock.Any(), gomock.Any()).Return(tx, nil)
|
|
|
|
// tx.EXPECT().End(gomock.Any(), gomock.Any()).Return(nil)
|
|
|
|
// SetPool(pool)
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// exporter, err := stdouttrace.New(stdouttrace.WithPrettyPrint())
|
|
|
|
// require.NoError(t, err)
|
|
|
|
// tracerProvider := sdktrace.NewTracerProvider(
|
|
|
|
// sdktrace.WithSyncer(exporter),
|
|
|
|
// )
|
|
|
|
// otel.SetTracerProvider(tracerProvider)
|
|
|
|
// SetTracer(tracing.Tracer{Tracer: tracerProvider.Tracer("test")})
|
|
|
|
// defer func() { assert.NoError(t, tracerProvider.Shutdown(ctx)) }()
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// SetLogger(logging.Logger{Logger: slog.Default()})
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// SetUserRepository(repository.UserRepository)
|
|
|
|
// SetOrgRepository(repository.OrgRepository)
|
|
|
|
// // SetInstanceRepository(repository.Instance)
|
|
|
|
// // SetCryptoRepository(repository.Crypto)
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// t.Run("create org", func(t *testing.T) {
|
|
|
|
// org := NewAddOrgCommand("testorg", NewAddMemberCommand("testuser", "ORG_OWNER"))
|
|
|
|
// user := NewCreateHumanCommand("testuser")
|
|
|
|
// err := Invoke(ctx, BatchCommands(org, user))
|
|
|
|
// assert.NoError(t, err)
|
|
|
|
// })
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// t.Run("verified email", func(t *testing.T) {
|
|
|
|
// err := Invoke(ctx, NewSetEmailCommand("u1", "test@example.com", NewEmailVerifiedCommand("u1", true)))
|
|
|
|
// assert.NoError(t, err)
|
|
|
|
// })
|
2025-05-08 15:30:06 +02:00
|
|
|
|
2025-06-13 17:05:37 +02:00
|
|
|
// t.Run("unverified email", func(t *testing.T) {
|
|
|
|
// err := Invoke(ctx, NewSetEmailCommand("u2", "test2@example.com", NewEmailVerifiedCommand("u2", false)))
|
|
|
|
// assert.NoError(t, err)
|
|
|
|
// })
|
|
|
|
// }
|