mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-13 10:57:32 +00:00
fixup! Merge branch 'clean-transactional-propsal' into instance_table
This commit is contained in:
@@ -142,13 +142,24 @@ func TestServer_TestInstanceDeleteReduces(t *testing.T) {
|
|||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
instanceRepo := repository.InstanceRepository(pool)
|
||||||
|
|
||||||
|
// check instance exists
|
||||||
|
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Minute)
|
||||||
|
assert.EventuallyWithT(t, func(ttt *assert.CollectT) {
|
||||||
|
instance, err := instanceRepo.Get(CTX,
|
||||||
|
instanceRepo.NameCondition(database.TextOperationEqual, instanceName),
|
||||||
|
)
|
||||||
|
require.NoError(ttt, err)
|
||||||
|
require.Equal(ttt, instanceName, instance.Name)
|
||||||
|
}, retryDuration, tick)
|
||||||
|
|
||||||
_, err = SystemClient.RemoveInstance(CTX, &system.RemoveInstanceRequest{
|
_, err = SystemClient.RemoveInstance(CTX, &system.RemoveInstanceRequest{
|
||||||
InstanceId: res.InstanceId,
|
InstanceId: res.InstanceId,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
instanceRepo := repository.InstanceRepository(pool)
|
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(CTX, time.Minute)
|
||||||
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Minute)
|
|
||||||
assert.EventuallyWithT(t, func(ttt *assert.CollectT) {
|
assert.EventuallyWithT(t, func(ttt *assert.CollectT) {
|
||||||
instance, err := instanceRepo.Get(CTX,
|
instance, err := instanceRepo.Get(CTX,
|
||||||
instanceRepo.NameCondition(database.TextOperationEqual, instanceName),
|
instanceRepo.NameCondition(database.TextOperationEqual, instanceName),
|
||||||
|
@@ -23,7 +23,7 @@ func runTests(m *testing.M) int {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
pool, stop, err = newEmbeededDB(ctx)
|
pool, stop, err = newEmbeededDB(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Printf("error with embedded postgres database: %v", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
defer stop()
|
defer stop()
|
||||||
|
@@ -1,142 +0,0 @@
|
|||||||
package repository_test
|
|
||||||
|
|
||||||
// import (
|
|
||||||
// "context"
|
|
||||||
// "testing"
|
|
||||||
|
|
||||||
// "github.com/stretchr/testify/assert"
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// "go.uber.org/mock/gomock"
|
|
||||||
|
|
||||||
// "github.com/zitadel/zitadel/backend/v3/storage/database"
|
|
||||||
// "github.com/zitadel/zitadel/backend/v3/storage/database/dbmock"
|
|
||||||
// "github.com/zitadel/zitadel/backend/v3/storage/database/repository"
|
|
||||||
// )
|
|
||||||
|
|
||||||
// func TestQueryUser(t *testing.T) {
|
|
||||||
// t.Skip("tests are meant as examples and are not real tests")
|
|
||||||
// t.Run("User filters", func(t *testing.T) {
|
|
||||||
// client := dbmock.NewMockClient(gomock.NewController(t))
|
|
||||||
|
|
||||||
// user := repository.UserRepository(client)
|
|
||||||
// u, err := user.Get(context.Background(),
|
|
||||||
// database.WithCondition(
|
|
||||||
// database.And(
|
|
||||||
// database.Or(
|
|
||||||
// user.IDCondition("test"),
|
|
||||||
// user.IDCondition("2"),
|
|
||||||
// ),
|
|
||||||
// user.UsernameCondition(database.TextOperationStartsWithIgnoreCase, "test"),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// database.WithOrderBy(user.CreatedAtColumn()),
|
|
||||||
// )
|
|
||||||
|
|
||||||
// assert.NoError(t, err)
|
|
||||||
// assert.NotNil(t, u)
|
|
||||||
// })
|
|
||||||
|
|
||||||
// t.Run("machine and human filters", func(t *testing.T) {
|
|
||||||
// client := dbmock.NewMockClient(gomock.NewController(t))
|
|
||||||
|
|
||||||
// user := repository.UserRepository(client)
|
|
||||||
// machine := user.Machine()
|
|
||||||
// human := user.Human()
|
|
||||||
// email, err := human.GetEmail(context.Background(), database.And(
|
|
||||||
// user.UsernameCondition(database.TextOperationStartsWithIgnoreCase, "test"),
|
|
||||||
// database.Or(
|
|
||||||
// machine.DescriptionCondition(database.TextOperationStartsWithIgnoreCase, "test"),
|
|
||||||
// human.EmailVerifiedCondition(true),
|
|
||||||
// database.IsNotNull(machine.DescriptionColumn()),
|
|
||||||
// ),
|
|
||||||
// ))
|
|
||||||
|
|
||||||
// assert.NoError(t, err)
|
|
||||||
// assert.NotNil(t, email)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type dbInstruction string
|
|
||||||
|
|
||||||
// func TestArg(t *testing.T) {
|
|
||||||
// var bla any = "asdf"
|
|
||||||
// instr, ok := bla.(dbInstruction)
|
|
||||||
// assert.False(t, ok)
|
|
||||||
// assert.Empty(t, instr)
|
|
||||||
// bla = dbInstruction("asdf")
|
|
||||||
// instr, ok = bla.(dbInstruction)
|
|
||||||
// assert.True(t, ok)
|
|
||||||
// assert.Equal(t, instr, dbInstruction("asdf"))
|
|
||||||
// }
|
|
||||||
|
|
||||||
=======
|
|
||||||
// "github.com/zitadel/zitadel/backend/v3/storage/database"
|
|
||||||
// "github.com/zitadel/zitadel/backend/v3/storage/database/dbmock"
|
|
||||||
// "github.com/zitadel/zitadel/backend/v3/storage/database/repository"
|
|
||||||
// "go.uber.org/mock/gomock"
|
|
||||||
// )
|
|
||||||
|
|
||||||
// func TestQueryUser(t *testing.T) {
|
|
||||||
// t.Skip("tests are meant as examples and are not real tests")
|
|
||||||
// t.Run("User filters", func(t *testing.T) {
|
|
||||||
// client := dbmock.NewMockClient(gomock.NewController(t))
|
|
||||||
|
|
||||||
// user := repository.UserRepository(client)
|
|
||||||
// u, err := user.Get(context.Background(),
|
|
||||||
// database.WithCondition(
|
|
||||||
// database.And(
|
|
||||||
// database.Or(
|
|
||||||
// user.IDCondition("test"),
|
|
||||||
// user.IDCondition("2"),
|
|
||||||
// ),
|
|
||||||
// user.UsernameCondition(database.TextOperationStartsWithIgnoreCase, "test"),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// database.WithOrderBy(user.CreatedAtColumn()),
|
|
||||||
// )
|
|
||||||
|
|
||||||
// assert.NoError(t, err)
|
|
||||||
// assert.NotNil(t, u)
|
|
||||||
// })
|
|
||||||
|
|
||||||
// t.Run("machine and human filters", func(t *testing.T) {
|
|
||||||
// client := dbmock.NewMockClient(gomock.NewController(t))
|
|
||||||
|
|
||||||
// user := repository.UserRepository(client)
|
|
||||||
// machine := user.Machine()
|
|
||||||
// human := user.Human()
|
|
||||||
// email, err := human.GetEmail(context.Background(), database.And(
|
|
||||||
// user.UsernameCondition(database.TextOperationStartsWithIgnoreCase, "test"),
|
|
||||||
// database.Or(
|
|
||||||
// machine.DescriptionCondition(database.TextOperationStartsWithIgnoreCase, "test"),
|
|
||||||
// human.EmailVerifiedCondition(true),
|
|
||||||
// database.IsNotNull(machine.DescriptionColumn()),
|
|
||||||
// ),
|
|
||||||
// ))
|
|
||||||
|
|
||||||
// assert.NoError(t, err)
|
|
||||||
// assert.NotNil(t, email)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type dbInstruction string
|
|
||||||
|
|
||||||
// func TestArg(t *testing.T) {
|
|
||||||
// var bla any = "asdf"
|
|
||||||
// instr, ok := bla.(dbInstruction)
|
|
||||||
// assert.False(t, ok)
|
|
||||||
// assert.Empty(t, instr)
|
|
||||||
// bla = dbInstruction("asdf")
|
|
||||||
// instr, ok = bla.(dbInstruction)
|
|
||||||
// assert.True(t, ok)
|
|
||||||
// assert.Equal(t, instr, dbInstruction("asdf"))
|
|
||||||
// }
|
|
||||||
|
|
||||||
>>>>>>> clean-transactional-propsal
|
|
||||||
// func TestWriteUser(t *testing.T) {
|
|
||||||
// t.Skip("tests are meant as examples and are not real tests")
|
|
||||||
// t.Run("update user", func(t *testing.T) {
|
|
||||||
// user := repository.UserRepository(nil)
|
|
||||||
// user.Human().Update(context.Background(), user.IDCondition("test"), user.SetUsername("test"))
|
|
||||||
// })
|
|
||||||
// }
|
|
@@ -1,77 +0,0 @@
|
|||||||
package repository_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"go.uber.org/mock/gomock"
|
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/backend/v3/storage/database"
|
|
||||||
"github.com/zitadel/zitadel/backend/v3/storage/database/dbmock"
|
|
||||||
"github.com/zitadel/zitadel/backend/v3/storage/database/repository"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestQueryUser(t *testing.T) {
|
|
||||||
t.Skip("tests are meant as examples and are not real tests")
|
|
||||||
t.Run("User filters", func(t *testing.T) {
|
|
||||||
client := dbmock.NewMockClient(gomock.NewController(t))
|
|
||||||
|
|
||||||
user := repository.UserRepository(client)
|
|
||||||
u, err := user.Get(context.Background(),
|
|
||||||
database.WithCondition(
|
|
||||||
database.And(
|
|
||||||
database.Or(
|
|
||||||
user.IDCondition("test"),
|
|
||||||
user.IDCondition("2"),
|
|
||||||
),
|
|
||||||
user.UsernameCondition(database.TextOperationStartsWithIgnoreCase, "test"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
database.WithOrderBy(user.CreatedAtColumn()),
|
|
||||||
)
|
|
||||||
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.NotNil(t, u)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("machine and human filters", func(t *testing.T) {
|
|
||||||
client := dbmock.NewMockClient(gomock.NewController(t))
|
|
||||||
|
|
||||||
user := repository.UserRepository(client)
|
|
||||||
machine := user.Machine()
|
|
||||||
human := user.Human()
|
|
||||||
email, err := human.GetEmail(context.Background(), database.And(
|
|
||||||
user.UsernameCondition(database.TextOperationStartsWithIgnoreCase, "test"),
|
|
||||||
database.Or(
|
|
||||||
machine.DescriptionCondition(database.TextOperationStartsWithIgnoreCase, "test"),
|
|
||||||
human.EmailVerifiedCondition(true),
|
|
||||||
database.IsNotNull(machine.DescriptionColumn()),
|
|
||||||
),
|
|
||||||
))
|
|
||||||
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.NotNil(t, email)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
type dbInstruction string
|
|
||||||
|
|
||||||
func TestArg(t *testing.T) {
|
|
||||||
var bla any = "asdf"
|
|
||||||
instr, ok := bla.(dbInstruction)
|
|
||||||
assert.False(t, ok)
|
|
||||||
assert.Empty(t, instr)
|
|
||||||
bla = dbInstruction("asdf")
|
|
||||||
instr, ok = bla.(dbInstruction)
|
|
||||||
assert.True(t, ok)
|
|
||||||
assert.Equal(t, instr, dbInstruction("asdf"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteUser(t *testing.T) {
|
|
||||||
t.Skip("tests are meant as examples and are not real tests")
|
|
||||||
t.Run("update user", func(t *testing.T) {
|
|
||||||
user := repository.UserRepository(nil)
|
|
||||||
user.Human().Update(context.Background(), user.IDCondition("test"), user.SetUsername("test"))
|
|
||||||
})
|
|
||||||
}
|
|
Reference in New Issue
Block a user