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

Add yesod test getCookies utility #1815

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

josephsumabat
Copy link

@josephsumabat josephsumabat commented Aug 17, 2023

Before submitting your PR, check that you've:

Recently was trying to write a test which required that I clear cookies and set them again later on in the test.

cookies <- YT.getCookies
YT.clearCookies

<do something with cookies after>....

Unfortunately getRequestCookies only allows you to access the cookies in a RequestBuilder site context since the type of request is RequestBuilder site () -> YesodExample site () thus something like

cookies <- request $ do
  getRequestCookies

unfortunately does not typecheck and you can only access the cookies from within the request builder. This PR adds the utility funciton getCookies which simply enables the first use case allowing cookies to be accessed outside of a request context without resorting to using an IORef

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

Copy link
Contributor

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! do you mind updating the cabal file to make an easy releate?

Thanks!

yesod-test/Yesod/Test.hs Outdated Show resolved Hide resolved
@josephsumabat josephsumabat force-pushed the add-yesod-test-getCookies-utility branch from ddb7e1a to 67fab78 Compare October 10, 2023 17:58
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.

2 participants