Skip to content

Commit

Permalink
Merge pull request #93 from dwyl/wildcard-http-post-mock
Browse files Browse the repository at this point in the history
Catch-all `HTTPoisonMock.post!`
  • Loading branch information
asntc authored Nov 6, 2023
2 parents c0edbbf + c62c19c commit 62b6c25
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/httpoison_mock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,8 @@ defmodule ElixirAuthGithub.HTTPoisonMock do
) do
%{body: "access_token=12345&scope=user"}
end

def post!(_url, _body, _headers, _options) do
%{body: "access_token=123456&scope=user"}
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule ElixirAuthGithub.Mixfile do
def project do
[
app: :elixir_auth_github,
version: "1.6.4",
version: "1.6.5",
elixir: "~> 1.12",
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
Expand Down
6 changes: 6 additions & 0 deletions test/elixir_auth_github_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ defmodule ElixirAuthGithubTest do
assert res.scope == "user"
end

test "catch-all mock HTTP.post! returns scope string" do
setup_test_environment_variables()
{:ok, res} = ElixirAuthGithub.github_auth("123456")
assert res.scope == "user"
end

test "github_auth returns an error with a bad code" do
setup_test_environment_variables()
assert ElixirAuthGithub.github_auth("1234") ==
Expand Down

0 comments on commit 62b6c25

Please sign in to comment.