Skip to content

Commit

Permalink
fix: in NewConfig() set host and call only if not set via config opti…
Browse files Browse the repository at this point in the history
…ons. fixes #237
  • Loading branch information
bojand committed Oct 23, 2020
1 parent 47cc6be commit 4f9a6ee
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,9 @@ func WithTemplateFuncs(funcMap template.FuncMap) Option {

// NewConfig creates a new RunConfig from the options passed
func NewConfig(call, host string, options ...Option) (*RunConfig, error) {
call = strings.TrimSpace(call)
host = strings.TrimSpace(host)

// init with defaults
c := &RunConfig{
call: call,
host: host,
n: 200,
c: 50,
nConns: 1,
Expand All @@ -593,6 +589,16 @@ func NewConfig(call, host string, options ...Option) (*RunConfig, error) {
}
}

// host and call may have been applied via options
// only override if not present
if c.host == "" {
c.host = strings.TrimSpace(host)
}

if c.call == "" {
c.call = strings.TrimSpace(call)
}

// fix up durations
if c.z > 0 {
c.n = math.MaxInt32
Expand Down

0 comments on commit 4f9a6ee

Please sign in to comment.