Skip to content

Commit 82b83c7

Browse files
fix: fix tests; auto register UUID for pgx
1 parent f07677a commit 82b83c7

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

http/httprequest/request.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ var (
2626
func DecodeJSON[T any](r *http.Request) (*T, error) {
2727
ctx := r.Context()
2828

29-
var v *T
30-
if err := json.NewDecoder(r.Body).Decode(v); err != nil {
29+
var v T
30+
if err := json.NewDecoder(r.Body).Decode(&v); err != nil {
3131
return nil, fmt.Errorf("http/request: unable to decode JSON: %w", err)
3232
}
3333

3434
if err := Validator.StructCtx(ctx, v); err != nil {
3535
return nil, err
3636
}
3737

38-
return v, nil
38+
return &v, nil
3939
}
4040

4141
// DecodeForm converts a url.Values (including form values) from the incoming

sqldb/internal/pgxuuid/pgxuuid_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// NOTE: the encoder is registered automatically for `dbtest` struct
1+
// The encoder is registered automatically for sqldbtest.DB via sqldb.WithUUID
22
// so no need to register it here.
33
package pgxuuid_test
44

@@ -19,6 +19,8 @@ func TestCodecDecodeValue(t *testing.T) {
1919
original, err := uuid.NewV7()
2020
require.NoError(t, err)
2121

22+
print("here")
23+
2224
rows, err := pool.Query(ctx, `select $1::uuid`, original)
2325
require.NoError(t, err)
2426

sqldb/sqldbtest/sqldbtest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func Must(ctx context.Context, tb testing.TB, opts ...func(*Config)) *DB {
105105
func MustWithConfig(ctx context.Context, tb testing.TB, config *Config) *DB {
106106
tb.Helper()
107107

108-
pool := sqldb.MustPool(ctx, config.DatabaseURI)
108+
pool := sqldb.MustPool(ctx, config.DatabaseURI, sqldb.WithUUID())
109109
db := &DB{
110110
config,
111111
tb,

0 commit comments

Comments
 (0)