Skip to content

Commit

Permalink
support custom template functions provided through RunConfig.funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
sprivitera committed Feb 24, 2021
1 parent b9aa837 commit ddb571b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions runner/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"strings"
"sync"
"text/template"

"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
Expand Down Expand Up @@ -63,7 +64,8 @@ type mdProvider struct {
}

func newDataProvider(mtd *desc.MethodDescriptor,
binary bool, dataFunc BinaryDataFunc, data []byte) (*dataProvider, error) {
binary bool, dataFunc BinaryDataFunc, data []byte,
funcs template.FuncMap) (*dataProvider, error) {

dp := dataProvider{
binary: binary,
Expand Down Expand Up @@ -96,7 +98,7 @@ func newDataProvider(mtd *desc.MethodDescriptor,
}

// Test if we can preseed data
ctd := newCallData(mtd, nil, "", 0)
ctd := newCallData(mtd, funcs, "", 0)
ha, err := ctd.hasAction(string(dp.data))
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion runner/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func NewRequester(c *RunConfig) (*Requester, error) {
if c.dataProviderFunc != nil {
reqr.dataProvider = c.dataProviderFunc
} else {
defaultDataProvider, err := newDataProvider(reqr.mtd, c.binary, c.dataFunc, c.data)
defaultDataProvider, err := newDataProvider(reqr.mtd, c.binary, c.dataFunc, c.data, c.funcs)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ddb571b

Please sign in to comment.