Skip to content

Commit

Permalink
fix(http.go): use more meaningful log message and format file
Browse files Browse the repository at this point in the history
  • Loading branch information
ArjitGopher committed Nov 15, 2024
1 parent f9bbc5c commit 29f1cdc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions js/modules/k6/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance {
}
}


validateArgCount := func(methodName string,args ...sobek.Value){
if len(args)>2 {
vu.State().Logger.Warningf("%s method has more than two arguments",methodName)
validateArgCount := func(methodName string, args ...sobek.Value) {
numberOfArgs := len(args)
if numberOfArgs > 2 {
vu.State().Logger.Warningf("http.%s method has more than two arguments, but %d were provided", methodName, len(args))
}
}

Expand All @@ -80,7 +80,7 @@ func (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance {
// as the third argument to http.request(method, url, body, params)

// get method should not have more than two arguments
validateArgCount("get",args...)
validateArgCount("get", args...)
args = append([]sobek.Value{sobek.Undefined()}, args...)
return mi.defaultClient.Request(http.MethodGet, url, args...)
})
Expand All @@ -89,7 +89,7 @@ func (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance {
// as the third argument to http.request(method, url, body, params)

// head method should not have more than two arguments
validateArgCount("head",args...)
validateArgCount("head", args...)
args = append([]sobek.Value{sobek.Undefined()}, args...)
return mi.defaultClient.Request(http.MethodHead, url, args...)
})
Expand Down

0 comments on commit 29f1cdc

Please sign in to comment.