diff --git a/ir/sample.go b/ir/sample.go index 73a7c8b4..4557a519 100644 --- a/ir/sample.go +++ b/ir/sample.go @@ -4,7 +4,6 @@ import ( "cmp" "slices" "strconv" - "strings" ) // ParamSample is a value a generated test sets a parameter to, and what the request must then carry for it. @@ -17,9 +16,9 @@ type ParamSample struct { } // ParamSamples are the query and header parameters of op a generated test can set and then find in the request, each -// with a value to set it to. A query parameter may be a scalar or an array of scalars, which the test sets to one -// item, the same on the wire in every style; a header parameter must be a scalar. Objects, maps and values with no -// plain text form, such as times, are left out. +// with a value to set it to. A query parameter may be a scalar or an array of scalars, named or not, which the test +// sets to one item, the same on the wire in every style; a header parameter must be a scalar. Objects, maps and values +// with no plain text form, such as times, are left out. func (doc Document) ParamSamples(op Operation) []ParamSample { var samples []ParamSample @@ -29,7 +28,7 @@ func (doc Document) ParamSamples(op Operation) []ParamSample { switch { case p.Props != nil, p.MapValue != nil: case p.Item != nil: - if lit, wire, ok := doc.scalarSample(*p.Item, len(samples)); ok && strings.HasPrefix(p.Type, "[]") { + if lit, wire, ok := doc.scalarSample(*p.Item, len(samples)); ok { samples = append(samples, ParamSample{Param: p, Literal: p.Type + "{" + lit + "}", Wire: wire}) } default: diff --git a/testdata/golden/pkg/golden/client.gen_test.go b/testdata/golden/pkg/golden/client.gen_test.go index 0536d487..bbcb6484 100644 --- a/testdata/golden/pkg/golden/client.gen_test.go +++ b/testdata/golden/pkg/golden/client.gen_test.go @@ -2315,14 +2315,15 @@ func TestClient_Params(t *testing.T) { } _ = c.QueryStyles(t.Context(), 0, QueryStylesParams{ - Csv: []int{2}, - Spaced: []string{""}, - Piped: []string{""}, - Next: "next", - Paths: []string{""}, - Cells: []string{""}, - Level: LevelThree, - Ratio: 9.5, + Csv: []int{2}, + Spaced: []string{""}, + Piped: []string{""}, + Next: "next", + Paths: []string{""}, + Cells: []string{""}, + Modules: Modules{ModuleSummaryDetail}, + Level: LevelThree, + Ratio: 10.5, }) if got == nil { @@ -2347,11 +2348,14 @@ func TestClient_Params(t *testing.T) { if v := got.URL.Query().Get("cells"); v != "" { t.Errorf("query %s: got %q, want %q", "cells", v, "") } + if v := got.URL.Query().Get("modules"); v != "summaryDetail" { + t.Errorf("query %s: got %q, want %q", "modules", v, "summaryDetail") + } if v := got.URL.Query().Get("level"); v != "3" { t.Errorf("query %s: got %q, want %q", "level", v, "3") } - if v := got.URL.Query().Get("ratio"); v != "9.5" { - t.Errorf("query %s: got %q, want %q", "ratio", v, "9.5") + if v := got.URL.Query().Get("ratio"); v != "10.5" { + t.Errorf("query %s: got %q, want %q", "ratio", v, "10.5") } }) }