-
Notifications
You must be signed in to change notification settings - Fork 79
[KOGITO-1729] Consolidate HTTP Request parameters into one struct type #361
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
test/framework/http.go
Outdated
if err != nil { | ||
return false, err | ||
} | ||
|
||
return strings.Contains(resultBody, responseContent), nil | ||
} | ||
|
||
// NewHTTPRequestInfo constructor creates a new HTTPRequestInfo struct | ||
func NewHTTPRequestInfo(httpMethod, uri, path, bodyFormat, bodyContent string) HTTPRequestInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about providing separate function for GET and POST types?
For GET type you don't need to supply bodyFormat and bodyContent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I was actually thinking about it, but just to get rid of GET and POST strings. But your suggestion is even better, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one suggestion in comment.
Added 2 methods:
I tried to change it to NewHTTPRequestInfoGET, but that would change the meaning slightly. Also I think GET should be all caps, so inevitably we will have a lot of capital letters together. If you know a better approach, feel free to suggest it. |
Looks good to me. |
Folks, this PR was not merged yet because the CI is reporting error? |
I guess so, seems to be approved and passing checks. |
Hi, on Friday I was unable to restart the build, but @radtriste did and not it is finally green! Merging. Thanks all for review. |
https://issues.redhat.com/browse/KOGITO-1729
JIRA was created as a result of the feedback in #257 (comment).
Things to discuss:
Name of the struct is
HTTPRequestInfo
.I didn't want to name it
HTTPRequest
as then the parameter name, e.g.request
, would clash with the actual request from Go's http package and it would be confusing in methods like for example here:https://github.com/kiegroup/kogito-cloud-operator/blob/e9069757dcc2fa0068019cc3a76d49a90719f139/test/framework/http.go#L53-L56 I was also considering
HTTPRequestData
but this isn't just data andHTTPRequestMetaData
but that's too long. The parameter would then need to be something likerequestMetaData
etc.I think the goal of the JIRA was achieved, HTTP methods have much shorter signatures now, but now we need to call the constructor to create an
HTTPRequestInfo
struct each time we want to issue a request. Also some logging methods are now longer as struct fields needs to be accessed using the prefix.I have also found a small bug, so I decided to fix that:
https://github.com/kiegroup/kogito-cloud-operator/blob/e9069757dcc2fa0068019cc3a76d49a90719f139/test/steps/http.go#L91-L92
Many thanks for submiting your Pull Request ❤️ 🏎️!
Please make sure that your PR meets the following requirements:
[KOGITO-XYZ] Subject