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"
|
||||
"errors"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -295,10 +296,5 @@ func TestDatabaseSQLDriverRegistered(t *testing.T) {
|
||||
}
|
||||
|
||||
func slicesContains(s []string, v string) bool {
|
||||
for _, x := range s {
|
||||
if x == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(s, v)
|
||||
}
|
||||
|
||||
@ -21,9 +21,9 @@ import (
|
||||
// DBTX interface, the same pgconn.CommandTag / pgx.Rows / pgx.Row signatures.
|
||||
|
||||
type DBTX interface {
|
||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
||||
Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
|
||||
Query(context.Context, string, ...any) (pgx.Rows, error)
|
||||
QueryRow(context.Context, string, ...any) pgx.Row
|
||||
}
|
||||
|
||||
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",
|
||||
resp: &abiv1.MenusGetMenuItemsResponse{Items: []*abiv1.MenuItem{{
|
||||
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",
|
||||
}}},
|
||||
run: func(t *testing.T, cs plugin.CoreServices) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user