diff --git a/backend/v3/storage/database/repository/instance.go b/backend/v3/storage/database/repository/instance.go index 448a55797a..0f5a29a071 100644 --- a/backend/v3/storage/database/repository/instance.go +++ b/backend/v3/storage/database/repository/instance.go @@ -119,7 +119,7 @@ func (i instance) Delete(ctx context.Context, condition database.Condition) erro if condition == nil { return errors.New("Delete must contain a condition") // (otherwise ALL instances will be deleted) } - builder := database.StatementBuilder{} + var builder database.StatementBuilder builder.WriteString(`UPDATE zitadel.instances SET deleted_at = $1`) builder.AppendArgs(time.Now()) diff --git a/backend/v3/storage/database/repository/user_test.go.orig b/backend/v3/storage/database/repository/user_test.go.orig new file mode 100644 index 0000000000..6f7ecd5592 --- /dev/null +++ b/backend/v3/storage/database/repository/user_test.go.orig @@ -0,0 +1,142 @@ +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")) +// }) +// }