test: modernize idiom in wasmguest tests (slices.Contains, any, new(v))
- driver_test.go: use slices.Contains instead of a hand-rolled loop
- sqlcgen_test.go: interface{} -> any in the generated-style DBTX shim
- caps_roundtrip_test.go: new(idParent.String()) instead of proto.String
for the pointer literal
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
cbc9ff495f
commit
5880aa21ee
@ -5,6 +5,7 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -295,10 +296,5 @@ func TestDatabaseSQLDriverRegistered(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func slicesContains(s []string, v string) bool {
|
func slicesContains(s []string, v string) bool {
|
||||||
for _, x := range s {
|
return slices.Contains(s, v)
|
||||||
if x == v {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,9 +21,9 @@ import (
|
|||||||
// DBTX interface, the same pgconn.CommandTag / pgx.Rows / pgx.Row signatures.
|
// DBTX interface, the same pgconn.CommandTag / pgx.Rows / pgx.Row signatures.
|
||||||
|
|
||||||
type DBTX interface {
|
type DBTX interface {
|
||||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
|
||||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
Query(context.Context, string, ...any) (pgx.Rows, error)
|
||||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
QueryRow(context.Context, string, ...any) pgx.Row
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(db DBTX) *Queries { return &Queries{db: db} }
|
func New(db DBTX) *Queries { return &Queries{db: db} }
|
||||||
|
|||||||
@ -322,7 +322,7 @@ func TestCapabilityRoundTrip(t *testing.T) {
|
|||||||
name: "menus_get_menu_items", wantMethod: "menus.get_menu_items",
|
name: "menus_get_menu_items", wantMethod: "menus.get_menu_items",
|
||||||
resp: &abiv1.MenusGetMenuItemsResponse{Items: []*abiv1.MenuItem{{
|
resp: &abiv1.MenusGetMenuItemsResponse{Items: []*abiv1.MenuItem{{
|
||||||
Id: idItem.String(), MenuId: idMenu.String(), Label: "Home", Url: "/",
|
Id: idItem.String(), MenuId: idMenu.String(), Label: "Home", Url: "/",
|
||||||
PageSlug: "home", ParentId: proto.String(idParent.String()), SortOrder: 1,
|
PageSlug: "home", ParentId: new(idParent.String()), SortOrder: 1,
|
||||||
OpenInNewTab: true, CssClass: "nav", ItemType: "link", Icon: "home",
|
OpenInNewTab: true, CssClass: "nav", ItemType: "link", Icon: "home",
|
||||||
}}},
|
}}},
|
||||||
run: func(t *testing.T, cs plugin.CoreServices) {
|
run: func(t *testing.T, cs plugin.CoreServices) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user