Skip to content

Commit

Permalink
fix: credo issues and dialyxir warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
saveman71 committed Oct 17, 2024
1 parent 7e98620 commit 9064d39
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lib/hcaptcha/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ defmodule Hcaptcha.Http do

result =
with {:ok, response} <-
HTTPoison.post(url, body, @headers, timeout: timeout),
{:ok, data} <- @json_library.decode(response.body) do
{:ok, data}
HTTPoison.post(url, body, @headers, timeout: timeout) do
@json_library.decode(response.body)
end

case result do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ defmodule Hcaptcha.Mixfile do
{:jason, "~> 1.4", optional: true},
{:credo, "~> 1.7.1", only: [:dev, :test], runtime: false},
{:ex_doc, "0.30.6", only: :dev},
{:dialyxir, "~> 1.4.1", only: [:test]},
{:dialyxir, "~> 1.4.1", only: [:test], runtime: false},
{:excoveralls, "~> 0.17.1", only: :test}
]
end
Expand Down
6 changes: 3 additions & 3 deletions test/hcaptcha_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule HcaptchaTest do
use ExUnit.Case, async: true

# see https://docs.hcaptcha.com/#integration-testing-test-keys
@hCaptcha_test_secret "0x0000000000000000000000000000000000000000"
@hcaptcha_test_secret "0x0000000000000000000000000000000000000000"

test "When the supplied hcaptcha-response is invalid, errors are returned" do
assert {:error, messages} = Hcaptcha.verify("not_valid")
Expand All @@ -12,13 +12,13 @@ defmodule HcaptchaTest do
test "When a valid response is supplied, a success response is returned" do
assert {:ok, %{challenge_ts: _, hostname: _}} =
Hcaptcha.verify("10000000-aaaa-bbbb-cccc-000000000001",
secret: @hCaptcha_test_secret
secret: @hcaptcha_test_secret
)
end

test "When an invalid response is supplied, an error response is returned" do
assert {:error, [:invalid_input_response]} =
Hcaptcha.verify("invalid_response", secret: @hCaptcha_test_secret)
Hcaptcha.verify("invalid_response", secret: @hcaptcha_test_secret)
end

test "When secret is not overridden the configured secret is used" do
Expand Down

0 comments on commit 9064d39

Please sign in to comment.