Fix token_server_test

This commit is contained in:
Adam Millerchip 2019-10-27 19:46:45 +09:00
parent 5d8f93c8b8
commit ff29abb417

View file

@ -62,8 +62,6 @@ defmodule LineBot.TokenServerTest do
test "when token has expired, fetches and returns new token, and adds it to state", %{ test "when token has expired, fetches and returns new token, and adds it to state", %{
state: state state: state
} do } do
headers = [{"Content-Type", "application/x-www-form-urlencoded"}]
data = [ data = [
grant_type: "client_credentials", grant_type: "client_credentials",
client_id: @client_id, client_id: @client_id,
@ -72,7 +70,10 @@ defmodule LineBot.TokenServerTest do
expect(MockAPIClient, :post!, fn "https://api.line.me/v2/oauth/accessToken", expect(MockAPIClient, :post!, fn "https://api.line.me/v2/oauth/accessToken",
{:form, ^data}, {:form, ^data},
^headers -> [
{"Content-Type", "application/x-www-form-urlencoded"},
{"User-Agent", "line-botsdk-elixir/v" <> _}
] ->
%{body: ~S'{"access_token":"new token", "expires_in":1000}'} %{body: ~S'{"access_token":"new token", "expires_in":1000}'}
end) end)
@ -96,7 +97,10 @@ defmodule LineBot.TokenServerTest do
test "calls purge API and sets token to nil and expiry to an expired date", %{state: state} do test "calls purge API and sets token to nil and expiry to an expired date", %{state: state} do
expect(MockAPIClient, :post!, fn "https://api.line.me/v2/oauth/revoke", expect(MockAPIClient, :post!, fn "https://api.line.me/v2/oauth/revoke",
{:form, [access_token: "original token"]}, {:form, [access_token: "original token"]},
[{"Content-Type", "application/x-www-form-urlencoded"}] -> [
{"Content-Type", "application/x-www-form-urlencoded"},
{"User-Agent", "line-botsdk-elixir/v" <> _}
] ->
:ok :ok
end) end)