Skip to content

Commit

Permalink
Merge pull request #295 from bojand/bin_data_template_action_fix
Browse files Browse the repository at this point in the history
do not attempt template actions with binary data. fixes #284
  • Loading branch information
bojand authored Aug 6, 2021
2 parents b3e3f4d + 9ea55ad commit a73afa9
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 106 deletions.
6 changes: 6 additions & 0 deletions internal/wrapped/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ type WrappedService struct{}
func (s *WrappedService) GetMessage(ctx context.Context, req *wrappers.StringValue) (*wrappers.StringValue, error) {
return &wrappers.StringValue{Value: "Hello: " + req.GetValue()}, nil
}

func (s *WrappedService) GetBytesMessage(ctx context.Context, req *wrappers.BytesValue) (*wrappers.BytesValue, error) {
return &wrappers.BytesValue{Value: req.GetValue()}, nil
}

func (s *WrappedService) mustEmbedUnimplementedWrappedServiceServer() {}
171 changes: 68 additions & 103 deletions internal/wrapped/wrapped.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 138 additions & 0 deletions internal/wrapped/wrapped_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions runner/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ func newDataProvider(mtd *desc.MethodDescriptor,

// Test if we can preseed data
ctd := newCallData(mtd, funcs, "", 0)
ha, err := ctd.hasAction(string(dp.data))
if err != nil {
return nil, err
ha := false
if !dp.binary {
ha, err = ctd.hasAction(string(dp.data))
if err != nil {
return nil, err
}
}

dp.hasActions = ha
Expand Down
4 changes: 4 additions & 0 deletions runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ func NewConfig(call, host string, options ...Option) (*RunConfig, error) {
return nil, errors.New("host required")
}

if c.binary && c.streamDynamicMessages {
return nil, errors.New("cannot use dynamic messages with binary data")
}

if c.loadSchedule != ScheduleConst &&
c.loadSchedule != ScheduleStep &&
c.loadSchedule != ScheduleLine {
Expand Down
11 changes: 11 additions & 0 deletions runner/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,17 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, c.enableCompression, false)
})

t.Run("with binary data from file and dynamic message", func(t *testing.T) {
c, err := NewConfig("call", "localhost:50050",
WithProtoFile("testdata/data.proto", []string{}),
WithBinaryDataFromFile("../testdata/hello_request_data.bin"),
WithStreamDynamicMessages(true),
)

assert.Error(t, err)
assert.Nil(t, c)
})

t.Run("with data from file", func(t *testing.T) {
c, err := NewConfig("call", "localhost:50050",
WithProtoFile("testdata/data.proto", []string{}),
Expand Down
Loading

0 comments on commit a73afa9

Please sign in to comment.