Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set default values in requests issued by a tdhttp.TestAPI #257

Closed
c-roussel opened this issue Jan 5, 2024 · 1 comment · Fixed by #258
Closed

Allow to set default values in requests issued by a tdhttp.TestAPI #257

c-roussel opened this issue Jan 5, 2024 · 1 comment · Fixed by #258

Comments

@c-roussel
Copy link

Hi,

On one of my projects there are a lot of tests using always a testAPI with the same set of headers such as:

var defaultHeaders http.Header
testAPI.Post("/my/route", json.RawMessage(`{}`),  defaultsHeaders).
  CmpStatus(http.StatusCreated).
  CmpJSONBody(...)

< Same last 3 lines over and over > 

I wonder if it'd be possible to directly set this kind of default values inside the testAPI itself, such as:

testAPI := tdhttp.NewTestAPI(t, testRouter).DefaultRequestParams(<INSERT DEFAULT HEADERS HERE>)
testAPI.Post("/my/route", json.RawMessage(`{}`)).
  CmpStatus(http.StatusCreated).
  CmpJSONBody(...)

< Same last 3 lines over and over > 
maxatome added a commit that referenced this issue Jan 11, 2024
…arams

Closes #257.

Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
maxatome added a commit that referenced this issue Jan 11, 2024
…arams

Closes #257.

Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
@maxatome
Copy link
Owner

Good idea, please take a look at #258 to see whether it matches your needs... or not...

maxatome added a commit that referenced this issue Jan 15, 2024
…arams

Closes #257.

Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
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 a pull request may close this issue.

2 participants