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

Create unit test for AssertionContext.Request and Response #269

Open
gavv opened this issue Feb 2, 2023 · 6 comments
Open

Create unit test for AssertionContext.Request and Response #269

gavv opened this issue Feb 2, 2023 · 6 comments
Assignees
Labels
help wanted Contributions are welcome tests Improvements or additions to tests

Comments

@gavv
Copy link
Owner

gavv commented Feb 2, 2023

Add a test to expect_test.go that verifies that:

  • AssertionContext.Request points to correct request
  • AssertionContext.Response points to correct response

When:

  • request reports failure (only AssertionContext.Request is set in this case)
  • response reports failure
  • child object of response reports failure (e.g. Response.Body)

For example, if you write this code:

req := e.GET("/test")
resp := req.Expect()
body := resp.Body()
body.IsEqual(...)

Then AssertionContext.Request should be set to req and AssertionContext.Response should be set to resp when req, resp, or body reports failure.

To inspect AssertionContext fields, the test should use a custom implementation of AssertionHandler. Then the test should imitate failure, and request, response, or body will invoke AssertionHandler.Failure and pass AssertionContext to it. Here is the point where the test can inspect context.

@gavv gavv added tests Improvements or additions to tests help wanted Contributions are welcome labels Feb 2, 2023
@gavv gavv pinned this issue Apr 4, 2023
@aliziyacevik
Copy link
Contributor

Hey there! I can take this.

@gavv
Copy link
Owner Author

gavv commented Apr 6, 2023

Thanks!

@gavv gavv unpinned this issue Apr 6, 2023
@gavv
Copy link
Owner Author

gavv commented Oct 1, 2023

@aliziyacevik Hi, do you still have plans on the issue?

@gavv gavv added the waiting reply Waiting for reply from reporter or contributor label Oct 1, 2023
@aliziyacevik
Copy link
Contributor

Yes, thanks for the reply :)

@gavv gavv removed the waiting reply Waiting for reply from reporter or contributor label Oct 2, 2023
@tomaszwysocki
Copy link

Hi @gavv, can I work on this?

@Arundas666
Copy link

hi @gavv is the issue still there? Can i work on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions are welcome tests Improvements or additions to tests
Projects
None yet
Development

No branches or pull requests

4 participants