Skip to content

test: start migrating dbauthz tests to mocked db #19257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
remove generic method signature in favor of 'any'
Depends on reflect under the hood anyway
  • Loading branch information
Emyrk committed Aug 8, 2025
commit e048a5162bb4817abdf930820cc23dd07f44c23d
9 changes: 7 additions & 2 deletions testutil/faker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ func Fake[T any](t *testing.T, faker *gofakeit.Faker, seed T) T {

// mergeZero merges the fields of src into dst, but only if the field in dst is
// currently the zero value.
func mergeZero[T any](dst *T, src T) {
// Make sure `dst` is a pointer to a struct, otherwise the fields are not assignable.
func mergeZero(dst any, src any) {
srcv := reflect.ValueOf(src)
if srcv.Kind() == reflect.Ptr {
srcv = srcv.Elem()
}
remain := [][2]reflect.Value{
{reflect.ValueOf(dst).Elem(), reflect.ValueOf(src)},
{reflect.ValueOf(dst).Elem(), srcv},
}

// Traverse the struct fields and set them only if they are currently zero.
Expand Down
Loading