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

Setup test environment with Goth #174

Open
RodolfoSilva opened this issue Aug 10, 2024 · 5 comments
Open

Setup test environment with Goth #174

RodolfoSilva opened this issue Aug 10, 2024 · 5 comments

Comments

@RodolfoSilva
Copy link

Is there an easy way to mock Goth.fetch!(MyApp.Goth) when running tests? For instance, I want to use the same dummy token when this is used in test mode.

@petermueller
Copy link

@RodolfoSilva, or maintainers, I can make a PR. I've had to solve this a few times and there's a decent pattern that could live as a test implementation or as documentation, or as an igniter module, depending on people's preference

@RodolfoSilva
Copy link
Author

@petermueller could you share this implementation? I think this PR will improve the library DX.

@Cyytrus
Copy link

Cyytrus commented Oct 10, 2024

Is there an easy way to mock Goth.fetch!(MyApp.Goth) when running tests? For instance, I want to use the same dummy token when this is used in test mode.

You can use Mock to custom your token response, like:

test "fetch token" do
    with_mock Goth, [fetch!: fn _ -> %Goth.Token{token: "XXXXX", type: "X", ...} end] do
      assert %Goth.Token{token: "XXXXX", type: "X", ...} == Goth.fetch!(MyApp.Goth)
    end
end

@gmile
Copy link

gmile commented Nov 21, 2024

@petermueller would be lovely to see how you are doing it 🙏

@mopp
Copy link

mopp commented Jan 15, 2025

Hi folks!
I would like to know how to handle the Goth in test env 👀

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

No branches or pull requests

5 participants