Skip to content

Conversation

@Montana
Copy link

@Montana Montana commented May 30, 2024

Hello @nytimes!

Instead of using http.CanonicalHeaderKey to check if a header exists, you can directly use the response.Header.Get(header) method.

So instead of using validateResponseHeaderPatterns function, instead of using http.CanonicalHeaderKey to check if a header exists, you can directly use the response.Header.Get(header) method. It automatically handles case-insensitive header names.

Use a switch statement instead of multiple if conditions for validating the HTTP method in the preProcessTest function. It will be more concise and easier to read.

Extract the header validation logic from validateResponseHeaders into separate functions for each type of assertion (patterns, notMatching, notPresent, ifPresentNotMatching).

This will make the code more modular and easier to understand. I've written these "updates" into this.

Cheers,
Michael Mendy

…s,, you can directly use the `response.Header.Get(header)` method.

So instead of using `validateResponseHeaderPatterns` function, instead of using `http.CanonicalHeaderKey` to check if a header exists, you can directly use the `response.Header.Get(header)` method. It automatically handles case-insensitive header names.

Use a switch statement instead of multiple if conditions for validating the HTTP method in the `preProcessTest` function. It will be more concise and easier to read.

Extract the header validation logic from validateResponseHeaders into separate functions for each type of assertion (patterns, `notMatching`, `notPresent`, `ifPresentNotMatching`). 

This will make the code more modular and easier to understand.
@Montana Montana requested a review from a team as a code owner May 30, 2024 17:38
@Montana Montana requested review from adamdabbracci, edonasaliu and mikeshort10 and removed request for a team May 30, 2024 17:38
@xawpaw
Copy link

xawpaw commented May 30, 2024

Really good call on using the switch statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants