mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:27:42 +00:00
chore(linting): changes to make clean-transactional-propsal_lint pass… (#10072)
This commit is contained in:
@@ -20,7 +20,7 @@ func (a *and) Write(builder *StatementBuilder) {
|
||||
if i > 0 {
|
||||
builder.WriteString(" AND ")
|
||||
}
|
||||
condition.(Condition).Write(builder)
|
||||
condition.Write(builder)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func (o *or) Write(builder *StatementBuilder) {
|
||||
if i > 0 {
|
||||
builder.WriteString(" OR ")
|
||||
}
|
||||
condition.(Condition).Write(builder)
|
||||
condition.Write(builder)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (i *isNotNull) Write(builder *StatementBuilder) {
|
||||
|
||||
// IsNotNull creates a condition that checks if a column is NOT NULL.
|
||||
func IsNotNull(column Column) *isNotNull {
|
||||
return &isNotNull{column: column.(Column)}
|
||||
return &isNotNull{column: column}
|
||||
}
|
||||
|
||||
var _ Condition = (*isNotNull)(nil)
|
||||
|
@@ -34,7 +34,7 @@ type Config struct {
|
||||
// // The value will be taken as is. Multiple options are space separated.
|
||||
// Options string
|
||||
|
||||
configuredFields []string
|
||||
// configuredFields []string
|
||||
}
|
||||
|
||||
// Connect implements [database.Connector].
|
||||
|
@@ -2,6 +2,7 @@ package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
@@ -25,7 +26,10 @@ func (tx *pgxTx) Rollback(ctx context.Context) error {
|
||||
// End implements [database.Transaction].
|
||||
func (tx *pgxTx) End(ctx context.Context, err error) error {
|
||||
if err != nil {
|
||||
tx.Rollback(ctx)
|
||||
rollbackErr := tx.Rollback(ctx)
|
||||
if rollbackErr != nil {
|
||||
err = errors.Join(err, rollbackErr)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return tx.Commit(ctx)
|
||||
|
@@ -46,7 +46,7 @@ func (opts *QueryOpts) WriteOrderBy(builder *StatementBuilder) {
|
||||
return
|
||||
}
|
||||
builder.WriteString(" ORDER BY ")
|
||||
Columns(opts.OrderBy).Write(builder)
|
||||
opts.OrderBy.Write(builder)
|
||||
}
|
||||
|
||||
func (opts *QueryOpts) WriteLimit(builder *StatementBuilder) {
|
||||
|
@@ -31,7 +31,6 @@ func (u *userHuman) GetEmail(ctx context.Context, condition database.Condition)
|
||||
&email.Address,
|
||||
&email.VerifiedAt,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -189,18 +188,18 @@ func (h userHuman) PhoneVerifiedAtColumn() database.Column {
|
||||
return database.NewColumn("phone_verified_at")
|
||||
}
|
||||
|
||||
func (h userHuman) columns() database.Columns {
|
||||
return append(h.user.columns(),
|
||||
h.FirstNameColumn(),
|
||||
h.LastNameColumn(),
|
||||
h.EmailAddressColumn(),
|
||||
h.EmailVerifiedAtColumn(),
|
||||
h.PhoneNumberColumn(),
|
||||
h.PhoneVerifiedAtColumn(),
|
||||
)
|
||||
}
|
||||
// func (h userHuman) columns() database.Columns {
|
||||
// return append(h.user.columns(),
|
||||
// h.FirstNameColumn(),
|
||||
// h.LastNameColumn(),
|
||||
// h.EmailAddressColumn(),
|
||||
// h.EmailVerifiedAtColumn(),
|
||||
// h.PhoneNumberColumn(),
|
||||
// h.PhoneVerifiedAtColumn(),
|
||||
// )
|
||||
// }
|
||||
|
||||
func (h userHuman) writeReturning(builder *database.StatementBuilder) {
|
||||
builder.WriteString(" RETURNING ")
|
||||
h.columns().Write(builder)
|
||||
}
|
||||
// func (h userHuman) writeReturning(builder *database.StatementBuilder) {
|
||||
// builder.WriteString(" RETURNING ")
|
||||
// h.columns().Write(builder)
|
||||
// }
|
||||
|
@@ -1,76 +1,76 @@
|
||||
package repository_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
// import (
|
||||
// "context"
|
||||
// "testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"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"
|
||||
)
|
||||
// "github.com/stretchr/testify/assert"
|
||||
// "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))
|
||||
// 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()),
|
||||
)
|
||||
// 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)
|
||||
})
|
||||
// assert.NoError(t, err)
|
||||
// assert.NotNil(t, u)
|
||||
// })
|
||||
|
||||
t.Run("machine and human filters", func(t *testing.T) {
|
||||
client := dbmock.NewMockClient(gomock.NewController(t))
|
||||
// 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()),
|
||||
),
|
||||
))
|
||||
// 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)
|
||||
})
|
||||
}
|
||||
// assert.NoError(t, err)
|
||||
// assert.NotNil(t, email)
|
||||
// })
|
||||
// }
|
||||
|
||||
type dbInstruction string
|
||||
// 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 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"))
|
||||
})
|
||||
}
|
||||
// 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