diff --git a/cmd/function.go b/cmd/function.go
index 6be2c84..067978e 100644
--- a/cmd/function.go
+++ b/cmd/function.go
@@ -1,46 +1,92 @@
package cmd
import (
+ "context"
+ "fmt"
"go/ast"
"go/doc"
"go/parser"
"go/token"
+ "io"
"path/filepath"
"reflect"
"runtime"
"strings"
+ "github.com/cucumber/godog"
"github.com/linuxsuren/api-testing/pkg/render"
"github.com/spf13/cobra"
)
func createFunctionCmd() (c *cobra.Command) {
+ opt := &funcPrinterOption{}
c = &cobra.Command{
Use: "func",
Short: "Print all the supported functions",
- RunE: func(cmd *cobra.Command, args []string) (err error) {
- if len(args) > 0 {
- name := args[0]
- if fn, ok := render.FuncMap()[name]; ok {
- cmd.Println(reflect.TypeOf(fn))
- desc := FuncDescription(fn)
- if desc != "" {
- cmd.Println(desc)
- }
- } else {
- cmd.Println("No such function")
- }
- } else {
- for name, fn := range render.FuncMap() {
- cmd.Println(name, reflect.TypeOf(fn))
- }
+ RunE: opt.runE,
+ }
+ flags := c.Flags()
+ flags.StringVarP(&opt.feature, "feature", "", "", "The feature query")
+ return
+}
+
+type funcPrinterOption struct {
+ feature string
+}
+
+func (o *funcPrinterOption) runE(cmd *cobra.Command, args []string) (err error) {
+ if len(args) > 0 {
+ name := args[0]
+ if fn, ok := render.FuncMap()[name]; ok {
+ cmd.Println(reflect.TypeOf(fn))
+ desc := FuncDescription(fn)
+ if desc != "" {
+ cmd.Println(desc)
}
- return
- },
+ } else {
+ cmd.Println("No such function")
+ }
+ } else if o.feature != "" {
+ ctx := context.WithValue(cmd.Context(), render.ContextBufferKey, cmd.OutOrStdout())
+
+ suite := godog.TestSuite{
+ ScenarioInitializer: initializeScenario,
+ Options: &godog.Options{
+ Format: "pretty",
+ ShowStepDefinitions: false,
+ FeatureContents: []godog.Feature{{
+ Name: "test",
+ Contents: []byte(fmt.Sprintf(`Feature: title
+ Scenario: generate
+ Given %s`, o.feature)),
+ }},
+ DefaultContext: ctx,
+ Output: io.Discard,
+ },
+ }
+
+ if suite.Run() != 0 {
+ err = fmt.Errorf("failed to query the feature")
+ } else {
+ cmd.Println()
+ }
+ } else {
+ for name, fn := range render.FuncMap() {
+ cmd.Println(name, reflect.TypeOf(fn))
+ }
}
return
}
+func initializeScenario(ctx *godog.ScenarioContext) {
+ funcs := render.GetAdvancedFuncs()
+ for _, fn := range funcs {
+ if fn.GoDogExper != "" && fn.Generator != nil {
+ ctx.Step(fn.GoDogExper, fn.Generator)
+ }
+ }
+}
+
// Get the name and path of a func
func FuncPathAndName(f interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name()
diff --git a/cmd/function_test.go b/cmd/function_test.go
index a6affda..7c5b60b 100644
--- a/cmd/function_test.go
+++ b/cmd/function_test.go
@@ -33,6 +33,19 @@ func TestCreateFunctionCommand(t *testing.T) {
verify: func(t *testing.T, output string) {
assert.Equal(t, "No such function\n", output)
},
+ }, {
+ name: "query functions, not found",
+ args: []string{"func", "--feature", `unknown`},
+ verify: func(t *testing.T, output string) {
+ assert.Equal(t, "\n", output)
+ },
+ }, {
+ name: "query functions, not found",
+ args: []string{"func", "--feature", `生成对象,字段包含 name`},
+ verify: func(t *testing.T, output string) {
+ assert.Equal(t, `{{generateJSONString "name"}}
+`, output)
+ },
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
diff --git a/console/atest-ui/src/App.vue b/console/atest-ui/src/App.vue
index 3a95ee4..0fe0588 100644
--- a/console/atest-ui/src/App.vue
+++ b/console/atest-ui/src/App.vue
@@ -1,6 +1,7 @@
+
+
+
+ Tool Box
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 1f21c90..b1d1be7 100644
--- a/go.mod
+++ b/go.mod
@@ -24,10 +24,17 @@ require (
require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
+ github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
+ github.com/cucumber/godog v0.12.6 // indirect
+ github.com/cucumber/messages-go/v16 v16.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
+ github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
+ github.com/hashicorp/go-memdb v1.3.2 // indirect
+ github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect
github.com/imdario/mergo v0.3.11 // indirect
diff --git a/go.sum b/go.sum
index 7907c43..b32525d 100644
--- a/go.sum
+++ b/go.sum
@@ -8,13 +8,24 @@ github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNg
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/antonmedv/expr v1.12.1 h1:GTGrGN1kxxb+le0uQKaFRK8By4cvq1sleUCGE/U6hHg=
github.com/antonmedv/expr v1.12.1/go.mod h1:FPC8iWArxls7axbVLsW+kpg1mz29A1b2M6jt+hZfDkU=
+github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/cucumber/gherkin-go/v19 v19.0.3 h1:mMSKu1077ffLbTJULUfM5HPokgeBcIGboyeNUof1MdE=
+github.com/cucumber/gherkin-go/v19 v19.0.3/go.mod h1:jY/NP6jUtRSArQQJ5h1FXOUgk5fZK24qtE7vKi776Vw=
+github.com/cucumber/godog v0.12.6 h1:3IToXviU45G7FgijwTk/LdB4iojn8zUFDfQLj4MMiHc=
+github.com/cucumber/godog v0.12.6/go.mod h1:Y02TTpimPXDb70PnG6M3zpODXm1+bjCsuZzcW76xAww=
+github.com/cucumber/messages-go/v16 v16.0.0/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g=
+github.com/cucumber/messages-go/v16 v16.0.1 h1:fvkpwsLgnIm0qugftrw2YwNlio+ABe2Iu94Ap8GMYIY=
+github.com/cucumber/messages-go/v16 v16.0.1/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
+github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
+github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
@@ -24,23 +35,37 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
github.com/h2non/gock v1.2.0 h1:K6ol8rfrRkUOefooBC8elXoaNGYkpp7y2qcxGG6BzUE=
github.com/h2non/gock v1.2.0/go.mod h1:tNhoxHYW2W42cYkYb1WqzdbYIieALC99kpYr7rH/BQk=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
+github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
+github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-memdb v1.3.2 h1:RBKHOsnSszpU6vxq80LzC2BaQjuuvoyaQbkLTf7V7g8=
+github.com/hashicorp/go-memdb v1.3.2/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
+github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
+github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk=
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
+github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/invopop/jsonschema v0.7.0 h1:2vgQcBz1n256N+FpX3Jq7Y17AjYt46Ig3zIWyy770So=
github.com/invopop/jsonschema v0.7.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0=
+github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
@@ -65,8 +90,11 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
+github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
@@ -79,6 +107,7 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
@@ -102,6 +131,7 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
@@ -130,6 +160,7 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -148,6 +179,7 @@ google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/pkg/render/template.go b/pkg/render/template.go
index b45a6a7..d1f58c0 100644
--- a/pkg/render/template.go
+++ b/pkg/render/template.go
@@ -2,6 +2,8 @@ package render
import (
"bytes"
+ "context"
+ "encoding/json"
"fmt"
"html/template"
"io"
@@ -28,8 +30,11 @@ func Render(name, text string, ctx interface{}) (result string, err error) {
// FuncMap reutrns all the supported functions
func FuncMap() template.FuncMap {
funcs := sprig.FuncMap()
- funcs["randomKubernetesName"] = func() string {
- return util.String(8)
+ for _, item := range GetAdvancedFuncs() {
+ if item.FuncName == "" || item.Func == nil {
+ continue
+ }
+ funcs[item.FuncName] = item.Func
}
return funcs
}
@@ -42,3 +47,78 @@ func RenderThenPrint(name, text string, ctx interface{}, w io.Writer) (err error
}
return
}
+
+var advancedFuncs = []AdvancedFunc{{
+ FuncName: "generateJSONString",
+ Func: generateJSONString,
+ GoDogExper: `^生成对象,字段包含 (.*)$`,
+ Generator: generateJSONObject,
+}, {
+ FuncName: "randomKubernetesName",
+ Func: func() string {
+ return util.String(8)
+ },
+ GoDogExper: `^动态k8s名称(.*)$`,
+ Generator: func(ctx context.Context, fields string) (err error) {
+ writeWithContext(ctx, `{{randomKubernetesName}}`)
+ return
+ },
+}, {
+ GoDogExper: `^生成随机字符串,长度 (.*)$`,
+ Generator: func(ctx context.Context, fields string) (err error) {
+ writeWithContext(ctx, `{{randAlpha `+fields+`}}`)
+ return
+ },
+}}
+
+// GetAdvancedFuncs returns all the advanced functions
+func GetAdvancedFuncs() []AdvancedFunc {
+ return advancedFuncs
+}
+
+func generateJSONString(fields []string) (result string) {
+ data := make(map[string]string)
+ for _, item := range fields {
+ data[item] = "random"
+ }
+
+ if json, err := json.Marshal(data); err == nil {
+ result = string(json)
+ }
+ return
+}
+
+type ContextKey string
+
+var ContextBufferKey ContextKey = "ContextBufferKey"
+
+// generateJSONObject generates a json object
+// For instance: {{generateJSONString "hello" "world"}}
+func generateJSONObject(ctx context.Context, fields string) (err error) {
+ items := strings.Split(fields, ",")
+ funcExp := "{{generateJSONString"
+ for _, item := range items {
+ funcExp += " \"" + strings.TrimSpace(item) + "\""
+ }
+ funcExp += "}}"
+
+ writeWithContext(ctx, funcExp)
+ return
+}
+
+func writeWithContext(ctx context.Context, text string) {
+ buf := ctx.Value(ContextBufferKey)
+ writer, ok := buf.(io.Writer)
+ if ok && writer != nil {
+ _, _ = writer.Write([]byte(text))
+ }
+ return
+}
+
+// AdvancedFunc represents an advanced function
+type AdvancedFunc struct {
+ FuncName string
+ Func interface{}
+ GoDogExper string
+ Generator func(ctx context.Context, fields string) (err error)
+}
diff --git a/pkg/render/template_test.go b/pkg/render/template_test.go
index 19adc91..d48914e 100644
--- a/pkg/render/template_test.go
+++ b/pkg/render/template_test.go
@@ -2,6 +2,7 @@ package render
import (
"bytes"
+ "context"
"testing"
"github.com/stretchr/testify/assert"
@@ -86,3 +87,70 @@ func TestRenderThenPrint(t *testing.T) {
})
}
}
+
+func TestFuncGenerator(t *testing.T) {
+ tests := []struct {
+ name string
+ funcName string
+ fields string
+ expect string
+ }{{
+ name: "randomKubernetesName",
+ funcName: "randomKubernetesName",
+ expect: `{{randomKubernetesName}}`,
+ }, {
+ name: "generateJSONString",
+ funcName: "generateJSONString",
+ fields: "name, age",
+ expect: `{{generateJSONString "name" "age"}}`,
+ }}
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ funcs := GetAdvancedFuncs()
+ for _, f := range funcs {
+ if f.FuncName == tt.funcName {
+ buf := new(bytes.Buffer)
+ ctx := context.Background()
+ ctx = context.WithValue(ctx, ContextBufferKey, buf)
+ err := f.Generator(ctx, tt.fields)
+ assert.NoError(t, err)
+ assert.Equal(t, tt.expect, buf.String())
+ }
+ }
+ })
+ }
+}
+
+func TestGoDogGenerator(t *testing.T) {
+ tests := []struct {
+ name string
+ goDogExper string
+ fields string
+ expect string
+ }{{
+ name: "randomKubernetesName",
+ goDogExper: `^生成随机字符串,长度 (.*)$`,
+ fields: `3`,
+ expect: `{{randAlpha 3}}`,
+ }}
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ funcs := GetAdvancedFuncs()
+ for _, f := range funcs {
+ if f.GoDogExper == tt.goDogExper {
+ buf := new(bytes.Buffer)
+ ctx := context.Background()
+ ctx = context.WithValue(ctx, ContextBufferKey, buf)
+ err := f.Generator(ctx, tt.fields)
+ assert.NoError(t, err)
+ assert.Equal(t, tt.expect, buf.String())
+ }
+ }
+ })
+ }
+}
+
+func TestGenerateJSONString(t *testing.T) {
+ result := generateJSONString([]string{"name", "age"})
+ assert.Equal(t, `{"age":"random","name":"random"}`, result)
+}
diff --git a/pkg/server/remote_server.go b/pkg/server/remote_server.go
index 7cc0f30..7ad113f 100644
--- a/pkg/server/remote_server.go
+++ b/pkg/server/remote_server.go
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"os"
+ reflect "reflect"
"regexp"
"strings"
@@ -467,6 +468,23 @@ func (s *server) GetSuggestedAPIs(ctx context.Context, in *TestSuiteIdentity) (r
return
}
+// FunctionsQuery returns a list of functions
+func (s *server) FunctionsQuery(ctx context.Context, in *SimpleQuery) (reply *Pairs, err error) {
+ reply = &Pairs{}
+ in.Name = strings.ToLower(in.Name)
+
+ for name, fn := range render.FuncMap() {
+ lowerCaseName := strings.ToLower(name)
+ if in.Name == "" || strings.Contains(lowerCaseName, in.Name) {
+ reply.Data = append(reply.Data, &Pair{
+ Key: name,
+ Value: fmt.Sprintf("%v", reflect.TypeOf(fn)),
+ })
+ }
+ }
+ return
+}
+
//go:embed data/headers.yaml
var popularHeaders string
diff --git a/pkg/server/remote_server_test.go b/pkg/server/remote_server_test.go
index 096bc9c..dda1d06 100644
--- a/pkg/server/remote_server_test.go
+++ b/pkg/server/remote_server_test.go
@@ -448,6 +448,27 @@ func TestGetSuggestedAPIs(t *testing.T) {
}
}
+func TestFunctionsQuery(t *testing.T) {
+ ctx := context.Background()
+ server := getRemoteServerInTempDir()
+
+ t.Run("match exactly", func(t *testing.T) {
+ reply, err := server.FunctionsQuery(ctx, &SimpleQuery{Name: "randNumeric"})
+ if assert.NoError(t, err) {
+ assert.Equal(t, 1, len(reply.Data))
+ assert.Equal(t, "randNumeric", reply.Data[0].Key)
+ assert.Equal(t, "func(int) string", reply.Data[0].Value)
+ }
+ })
+
+ t.Run("ignore letter case", func(t *testing.T) {
+ reply, err := server.FunctionsQuery(ctx, &SimpleQuery{Name: "randnumer"})
+ if assert.NoError(t, err) {
+ assert.Equal(t, 1, len(reply.Data))
+ }
+ })
+}
+
func getRemoteServerInTempDir() (server RunnerServer) {
writer := atesting.NewFileWriter(os.TempDir())
server = NewRemoteServer(writer)
diff --git a/pkg/server/server.pb.go b/pkg/server/server.pb.go
index 6946f09..be6b323 100644
--- a/pkg/server/server.pb.go
+++ b/pkg/server/server.pb.go
@@ -1130,6 +1130,53 @@ func (x *Pairs) GetData() []*Pair {
return nil
}
+type SimpleQuery struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (x *SimpleQuery) Reset() {
+ *x = SimpleQuery{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_pkg_server_server_proto_msgTypes[18]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *SimpleQuery) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SimpleQuery) ProtoMessage() {}
+
+func (x *SimpleQuery) ProtoReflect() protoreflect.Message {
+ mi := &file_pkg_server_server_proto_msgTypes[18]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use SimpleQuery.ProtoReflect.Descriptor instead.
+func (*SimpleQuery) Descriptor() ([]byte, []int) {
+ return file_pkg_server_server_proto_rawDescGZIP(), []int{18}
+}
+
+func (x *SimpleQuery) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
type Empty struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -1139,7 +1186,7 @@ type Empty struct {
func (x *Empty) Reset() {
*x = Empty{}
if protoimpl.UnsafeEnabled {
- mi := &file_pkg_server_server_proto_msgTypes[18]
+ mi := &file_pkg_server_server_proto_msgTypes[19]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1152,7 +1199,7 @@ func (x *Empty) String() string {
func (*Empty) ProtoMessage() {}
func (x *Empty) ProtoReflect() protoreflect.Message {
- mi := &file_pkg_server_server_proto_msgTypes[18]
+ mi := &file_pkg_server_server_proto_msgTypes[19]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1165,7 +1212,7 @@ func (x *Empty) ProtoReflect() protoreflect.Message {
// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
func (*Empty) Descriptor() ([]byte, []int) {
- return file_pkg_server_server_proto_rawDescGZIP(), []int{18}
+ return file_pkg_server_server_proto_rawDescGZIP(), []int{19}
}
var File_pkg_server_server_proto protoreflect.FileDescriptor
@@ -1286,72 +1333,77 @@ var file_pkg_server_server_proto_rawDesc = []byte{
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x29,
0x0a, 0x05, 0x50, 0x61, 0x69, 0x72, 0x73, 0x12, 0x20, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x50,
- 0x61, 0x69, 0x72, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70,
- 0x74, 0x79, 0x32, 0xc5, 0x07, 0x0a, 0x06, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x12, 0x2d, 0x0a,
- 0x03, 0x52, 0x75, 0x6e, 0x12, 0x10, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65,
- 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e,
- 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x00, 0x12, 0x2d, 0x0a, 0x06,
- 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e,
- 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48,
- 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x0a, 0x47,
- 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76,
+ 0x61, 0x69, 0x72, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x21, 0x0a, 0x0b, 0x53, 0x69, 0x6d,
+ 0x70, 0x6c, 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
+ 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x07, 0x0a, 0x05,
+ 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0xfd, 0x07, 0x0a, 0x06, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72,
+ 0x12, 0x2d, 0x0a, 0x03, 0x52, 0x75, 0x6e, 0x12, 0x10, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
+ 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76,
+ 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x00, 0x12,
+ 0x2d, 0x0a, 0x06, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76,
0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65,
- 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x2c,
- 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x12, 0x0d, 0x2e, 0x73, 0x65,
- 0x72, 0x76, 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0e, 0x2e, 0x73, 0x65, 0x72,
- 0x76, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x0f,
- 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x12,
- 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69,
- 0x74, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72,
- 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00,
- 0x12, 0x3e, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69, 0x74, 0x65,
- 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75,
- 0x69, 0x74, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x73, 0x65,
- 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x22, 0x00,
- 0x12, 0x3a, 0x0a, 0x0f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75,
- 0x69, 0x74, 0x65, 0x12, 0x11, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73,
- 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e,
- 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x0f,
- 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x12,
- 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69,
- 0x74, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72,
- 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00,
- 0x12, 0x3a, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65,
- 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75,
- 0x69, 0x74, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x73, 0x65,
- 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x69, 0x74, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x0b,
- 0x52, 0x75, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x12, 0x18, 0x2e, 0x73, 0x65,
- 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65,
- 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54,
- 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x00, 0x12,
- 0x3b, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x12, 0x18,
- 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65,
- 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x10, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65,
- 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x0e,
- 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x12, 0x19,
- 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65,
- 0x57, 0x69, 0x74, 0x68, 0x53, 0x75, 0x69, 0x74, 0x65, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76,
+ 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x31,
+ 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0d, 0x2e, 0x73,
+ 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x73, 0x65,
+ 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22,
+ 0x00, 0x12, 0x2c, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x12, 0x0d,
+ 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0e, 0x2e,
+ 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x22, 0x00, 0x12,
+ 0x42, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69,
+ 0x74, 0x65, 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74,
+ 0x53, 0x75, 0x69, 0x74, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x12, 0x2e,
+ 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c,
+ 0x79, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75,
+ 0x69, 0x74, 0x65, 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73,
+ 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x11,
+ 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69, 0x74,
+ 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x73,
+ 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x12, 0x11, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e,
+ 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76,
0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12,
- 0x41, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73,
+ 0x42, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69,
+ 0x74, 0x65, 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74,
+ 0x53, 0x75, 0x69, 0x74, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x12, 0x2e,
+ 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c,
+ 0x79, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x73, 0x74, 0x43,
+ 0x61, 0x73, 0x65, 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73,
+ 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x0d,
+ 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x69, 0x74, 0x65, 0x22, 0x00, 0x12,
+ 0x41, 0x0a, 0x0b, 0x52, 0x75, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x12, 0x18,
+ 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65,
+ 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65,
+ 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74,
+ 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73,
+ 0x65, 0x12, 0x18, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43,
+ 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x10, 0x2e, 0x73, 0x65,
+ 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x22, 0x00, 0x12,
+ 0x41, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73,
0x65, 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43,
0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x53, 0x75, 0x69, 0x74, 0x65, 0x1a, 0x12, 0x2e, 0x73,
0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79,
- 0x22, 0x00, 0x12, 0x40, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74,
- 0x43, 0x61, 0x73, 0x65, 0x12, 0x18, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65,
- 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x12,
- 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70,
- 0x6c, 0x79, 0x22, 0x00, 0x12, 0x30, 0x0a, 0x0e, 0x50, 0x6f, 0x70, 0x75, 0x6c, 0x61, 0x72, 0x48,
- 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e,
- 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x50,
- 0x61, 0x69, 0x72, 0x73, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x75, 0x67,
- 0x67, 0x65, 0x73, 0x74, 0x65, 0x64, 0x41, 0x50, 0x49, 0x73, 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72,
- 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69, 0x74, 0x65, 0x49, 0x64, 0x65,
- 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54,
- 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x73, 0x22, 0x00, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69,
- 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x6e, 0x75, 0x78, 0x73, 0x75,
- 0x72, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2f,
- 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x33,
+ 0x22, 0x00, 0x12, 0x41, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x73, 0x74,
+ 0x43, 0x61, 0x73, 0x65, 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65,
+ 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x53, 0x75, 0x69, 0x74, 0x65, 0x1a,
+ 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65,
+ 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54,
+ 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x12, 0x18, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
+ 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74,
+ 0x79, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f,
+ 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x30, 0x0a, 0x0e, 0x50, 0x6f, 0x70, 0x75, 0x6c,
+ 0x61, 0x72, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76,
+ 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65,
+ 0x72, 0x2e, 0x50, 0x61, 0x69, 0x72, 0x73, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x10, 0x47, 0x65, 0x74,
+ 0x53, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x65, 0x64, 0x41, 0x50, 0x49, 0x73, 0x12, 0x19, 0x2e,
+ 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x69, 0x74, 0x65,
+ 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65,
+ 0x72, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x73, 0x65, 0x73, 0x22, 0x00, 0x12, 0x36, 0x0a,
+ 0x0e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12,
+ 0x13, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x51,
+ 0x75, 0x65, 0x72, 0x79, 0x1a, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x50, 0x61,
+ 0x69, 0x72, 0x73, 0x22, 0x00, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
+ 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x6e, 0x75, 0x78, 0x73, 0x75, 0x72, 0x65, 0x6e, 0x2f, 0x61,
+ 0x70, 0x69, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x73,
+ 0x65, 0x72, 0x76, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -1366,7 +1418,7 @@ func file_pkg_server_server_proto_rawDescGZIP() []byte {
return file_pkg_server_server_proto_rawDescData
}
-var file_pkg_server_server_proto_msgTypes = make([]protoimpl.MessageInfo, 21)
+var file_pkg_server_server_proto_msgTypes = make([]protoimpl.MessageInfo, 22)
var file_pkg_server_server_proto_goTypes = []interface{}{
(*Suites)(nil), // 0: server.Suites
(*Items)(nil), // 1: server.Items
@@ -1386,14 +1438,15 @@ var file_pkg_server_server_proto_goTypes = []interface{}{
(*TestCaseResult)(nil), // 15: server.TestCaseResult
(*Pair)(nil), // 16: server.Pair
(*Pairs)(nil), // 17: server.Pairs
- (*Empty)(nil), // 18: server.Empty
- nil, // 19: server.Suites.DataEntry
- nil, // 20: server.TestTask.EnvEntry
+ (*SimpleQuery)(nil), // 18: server.SimpleQuery
+ (*Empty)(nil), // 19: server.Empty
+ nil, // 20: server.Suites.DataEntry
+ nil, // 21: server.TestTask.EnvEntry
}
var file_pkg_server_server_proto_depIdxs = []int32{
- 19, // 0: server.Suites.data:type_name -> server.Suites.DataEntry
+ 20, // 0: server.Suites.data:type_name -> server.Suites.DataEntry
4, // 1: server.TestSuite.spec:type_name -> server.APISpec
- 20, // 2: server.TestTask.env:type_name -> server.TestTask.EnvEntry
+ 21, // 2: server.TestTask.env:type_name -> server.TestTask.EnvEntry
15, // 3: server.TestResult.testCaseResult:type_name -> server.TestCaseResult
12, // 4: server.Suite.items:type_name -> server.TestCase
12, // 5: server.TestCaseWithSuite.data:type_name -> server.TestCase
@@ -1409,9 +1462,9 @@ var file_pkg_server_server_proto_depIdxs = []int32{
16, // 15: server.Pairs.data:type_name -> server.Pair
1, // 16: server.Suites.DataEntry.value:type_name -> server.Items
6, // 17: server.Runner.Run:input_type -> server.TestTask
- 18, // 18: server.Runner.Sample:input_type -> server.Empty
- 18, // 19: server.Runner.GetVersion:input_type -> server.Empty
- 18, // 20: server.Runner.GetSuites:input_type -> server.Empty
+ 19, // 18: server.Runner.Sample:input_type -> server.Empty
+ 19, // 19: server.Runner.GetVersion:input_type -> server.Empty
+ 19, // 20: server.Runner.GetSuites:input_type -> server.Empty
5, // 21: server.Runner.CreateTestSuite:input_type -> server.TestSuiteIdentity
5, // 22: server.Runner.GetTestSuite:input_type -> server.TestSuiteIdentity
3, // 23: server.Runner.UpdateTestSuite:input_type -> server.TestSuite
@@ -1422,26 +1475,28 @@ var file_pkg_server_server_proto_depIdxs = []int32{
10, // 28: server.Runner.CreateTestCase:input_type -> server.TestCaseWithSuite
10, // 29: server.Runner.UpdateTestCase:input_type -> server.TestCaseWithSuite
2, // 30: server.Runner.DeleteTestCase:input_type -> server.TestCaseIdentity
- 18, // 31: server.Runner.PopularHeaders:input_type -> server.Empty
+ 19, // 31: server.Runner.PopularHeaders:input_type -> server.Empty
5, // 32: server.Runner.GetSuggestedAPIs:input_type -> server.TestSuiteIdentity
- 7, // 33: server.Runner.Run:output_type -> server.TestResult
- 8, // 34: server.Runner.Sample:output_type -> server.HelloReply
- 8, // 35: server.Runner.GetVersion:output_type -> server.HelloReply
- 0, // 36: server.Runner.GetSuites:output_type -> server.Suites
- 8, // 37: server.Runner.CreateTestSuite:output_type -> server.HelloReply
- 3, // 38: server.Runner.GetTestSuite:output_type -> server.TestSuite
- 8, // 39: server.Runner.UpdateTestSuite:output_type -> server.HelloReply
- 8, // 40: server.Runner.DeleteTestSuite:output_type -> server.HelloReply
- 9, // 41: server.Runner.ListTestCase:output_type -> server.Suite
- 15, // 42: server.Runner.RunTestCase:output_type -> server.TestCaseResult
- 12, // 43: server.Runner.GetTestCase:output_type -> server.TestCase
- 8, // 44: server.Runner.CreateTestCase:output_type -> server.HelloReply
- 8, // 45: server.Runner.UpdateTestCase:output_type -> server.HelloReply
- 8, // 46: server.Runner.DeleteTestCase:output_type -> server.HelloReply
- 17, // 47: server.Runner.PopularHeaders:output_type -> server.Pairs
- 11, // 48: server.Runner.GetSuggestedAPIs:output_type -> server.TestCases
- 33, // [33:49] is the sub-list for method output_type
- 17, // [17:33] is the sub-list for method input_type
+ 18, // 33: server.Runner.FunctionsQuery:input_type -> server.SimpleQuery
+ 7, // 34: server.Runner.Run:output_type -> server.TestResult
+ 8, // 35: server.Runner.Sample:output_type -> server.HelloReply
+ 8, // 36: server.Runner.GetVersion:output_type -> server.HelloReply
+ 0, // 37: server.Runner.GetSuites:output_type -> server.Suites
+ 8, // 38: server.Runner.CreateTestSuite:output_type -> server.HelloReply
+ 3, // 39: server.Runner.GetTestSuite:output_type -> server.TestSuite
+ 8, // 40: server.Runner.UpdateTestSuite:output_type -> server.HelloReply
+ 8, // 41: server.Runner.DeleteTestSuite:output_type -> server.HelloReply
+ 9, // 42: server.Runner.ListTestCase:output_type -> server.Suite
+ 15, // 43: server.Runner.RunTestCase:output_type -> server.TestCaseResult
+ 12, // 44: server.Runner.GetTestCase:output_type -> server.TestCase
+ 8, // 45: server.Runner.CreateTestCase:output_type -> server.HelloReply
+ 8, // 46: server.Runner.UpdateTestCase:output_type -> server.HelloReply
+ 8, // 47: server.Runner.DeleteTestCase:output_type -> server.HelloReply
+ 17, // 48: server.Runner.PopularHeaders:output_type -> server.Pairs
+ 11, // 49: server.Runner.GetSuggestedAPIs:output_type -> server.TestCases
+ 17, // 50: server.Runner.FunctionsQuery:output_type -> server.Pairs
+ 34, // [34:51] is the sub-list for method output_type
+ 17, // [17:34] is the sub-list for method input_type
17, // [17:17] is the sub-list for extension type_name
17, // [17:17] is the sub-list for extension extendee
0, // [0:17] is the sub-list for field type_name
@@ -1670,6 +1725,18 @@ func file_pkg_server_server_proto_init() {
}
}
file_pkg_server_server_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*SimpleQuery); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_pkg_server_server_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Empty); i {
case 0:
return &v.state
@@ -1688,7 +1755,7 @@ func file_pkg_server_server_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_pkg_server_server_proto_rawDesc,
NumEnums: 0,
- NumMessages: 21,
+ NumMessages: 22,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/pkg/server/server.pb.gw.go b/pkg/server/server.pb.gw.go
index 8daf95d..9815d72 100644
--- a/pkg/server/server.pb.gw.go
+++ b/pkg/server/server.pb.gw.go
@@ -575,6 +575,40 @@ func local_request_Runner_GetSuggestedAPIs_0(ctx context.Context, marshaler runt
}
+func request_Runner_FunctionsQuery_0(ctx context.Context, marshaler runtime.Marshaler, client RunnerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq SimpleQuery
+ var metadata runtime.ServerMetadata
+
+ newReader, berr := utilities.IOReaderFactory(req.Body)
+ if berr != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
+ }
+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.FunctionsQuery(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_Runner_FunctionsQuery_0(ctx context.Context, marshaler runtime.Marshaler, server RunnerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq SimpleQuery
+ var metadata runtime.ServerMetadata
+
+ newReader, berr := utilities.IOReaderFactory(req.Body)
+ if berr != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
+ }
+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := server.FunctionsQuery(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
// RegisterRunnerHandlerServer registers the http handlers for service Runner to "mux".
// UnaryRPC :call RunnerServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@@ -981,6 +1015,31 @@ func RegisterRunnerHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser
})
+ mux.Handle("POST", pattern_Runner_FunctionsQuery_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/server.Runner/FunctionsQuery", runtime.WithHTTPPathPattern("/server.Runner/FunctionsQuery"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_Runner_FunctionsQuery_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Runner_FunctionsQuery_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
return nil
}
@@ -1374,6 +1433,28 @@ func RegisterRunnerHandlerClient(ctx context.Context, mux *runtime.ServeMux, cli
})
+ mux.Handle("POST", pattern_Runner_FunctionsQuery_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/server.Runner/FunctionsQuery", runtime.WithHTTPPathPattern("/server.Runner/FunctionsQuery"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_Runner_FunctionsQuery_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Runner_FunctionsQuery_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
return nil
}
@@ -1409,6 +1490,8 @@ var (
pattern_Runner_PopularHeaders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"server.Runner", "PopularHeaders"}, ""))
pattern_Runner_GetSuggestedAPIs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"server.Runner", "GetSuggestedAPIs"}, ""))
+
+ pattern_Runner_FunctionsQuery_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"server.Runner", "FunctionsQuery"}, ""))
)
var (
@@ -1443,4 +1526,6 @@ var (
forward_Runner_PopularHeaders_0 = runtime.ForwardResponseMessage
forward_Runner_GetSuggestedAPIs_0 = runtime.ForwardResponseMessage
+
+ forward_Runner_FunctionsQuery_0 = runtime.ForwardResponseMessage
)
diff --git a/pkg/server/server.proto b/pkg/server/server.proto
index 7dab51f..379bdfd 100644
--- a/pkg/server/server.proto
+++ b/pkg/server/server.proto
@@ -25,6 +25,7 @@ service Runner {
rpc PopularHeaders(Empty) returns (Pairs) {}
rpc GetSuggestedAPIs(TestSuiteIdentity) returns (TestCases) {}
+ rpc FunctionsQuery(SimpleQuery) returns (Pairs) {}
}
message Suites {
@@ -132,5 +133,9 @@ message Pairs {
repeated Pair data = 1;
}
+message SimpleQuery {
+ string name = 1;
+}
+
message Empty {
}
diff --git a/pkg/server/server_grpc.pb.go b/pkg/server/server_grpc.pb.go
index cef7bd4..22f09e3 100644
--- a/pkg/server/server_grpc.pb.go
+++ b/pkg/server/server_grpc.pb.go
@@ -38,6 +38,7 @@ type RunnerClient interface {
DeleteTestCase(ctx context.Context, in *TestCaseIdentity, opts ...grpc.CallOption) (*HelloReply, error)
PopularHeaders(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Pairs, error)
GetSuggestedAPIs(ctx context.Context, in *TestSuiteIdentity, opts ...grpc.CallOption) (*TestCases, error)
+ FunctionsQuery(ctx context.Context, in *SimpleQuery, opts ...grpc.CallOption) (*Pairs, error)
}
type runnerClient struct {
@@ -192,6 +193,15 @@ func (c *runnerClient) GetSuggestedAPIs(ctx context.Context, in *TestSuiteIdenti
return out, nil
}
+func (c *runnerClient) FunctionsQuery(ctx context.Context, in *SimpleQuery, opts ...grpc.CallOption) (*Pairs, error) {
+ out := new(Pairs)
+ err := c.cc.Invoke(ctx, "/server.Runner/FunctionsQuery", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
// RunnerServer is the server API for Runner service.
// All implementations must embed UnimplementedRunnerServer
// for forward compatibility
@@ -212,6 +222,7 @@ type RunnerServer interface {
DeleteTestCase(context.Context, *TestCaseIdentity) (*HelloReply, error)
PopularHeaders(context.Context, *Empty) (*Pairs, error)
GetSuggestedAPIs(context.Context, *TestSuiteIdentity) (*TestCases, error)
+ FunctionsQuery(context.Context, *SimpleQuery) (*Pairs, error)
mustEmbedUnimplementedRunnerServer()
}
@@ -267,6 +278,9 @@ func (UnimplementedRunnerServer) PopularHeaders(context.Context, *Empty) (*Pairs
func (UnimplementedRunnerServer) GetSuggestedAPIs(context.Context, *TestSuiteIdentity) (*TestCases, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSuggestedAPIs not implemented")
}
+func (UnimplementedRunnerServer) FunctionsQuery(context.Context, *SimpleQuery) (*Pairs, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method FunctionsQuery not implemented")
+}
func (UnimplementedRunnerServer) mustEmbedUnimplementedRunnerServer() {}
// UnsafeRunnerServer may be embedded to opt out of forward compatibility for this service.
@@ -568,6 +582,24 @@ func _Runner_GetSuggestedAPIs_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
+func _Runner_FunctionsQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(SimpleQuery)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(RunnerServer).FunctionsQuery(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/server.Runner/FunctionsQuery",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(RunnerServer).FunctionsQuery(ctx, req.(*SimpleQuery))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
// Runner_ServiceDesc is the grpc.ServiceDesc for Runner service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -639,6 +671,10 @@ var Runner_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetSuggestedAPIs",
Handler: _Runner_GetSuggestedAPIs_Handler,
},
+ {
+ MethodName: "FunctionsQuery",
+ Handler: _Runner_FunctionsQuery_Handler,
+ },
},
Streams: []grpc.StreamDesc{},
Metadata: "pkg/server/server.proto",