From ff29abb417d42875bbdf84934199933362d833e9 Mon Sep 17 00:00:00 2001 From: Adam Millerchip Date: Sun, 27 Oct 2019 19:46:45 +0900 Subject: [PATCH] Fix token_server_test --- test/line_bot/token_server_test.exs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/line_bot/token_server_test.exs b/test/line_bot/token_server_test.exs index bc7bc09..37c0e7e 100644 --- a/test/line_bot/token_server_test.exs +++ b/test/line_bot/token_server_test.exs @@ -62,8 +62,6 @@ defmodule LineBot.TokenServerTest do test "when token has expired, fetches and returns new token, and adds it to state", %{ state: state } do - headers = [{"Content-Type", "application/x-www-form-urlencoded"}] - data = [ grant_type: "client_credentials", client_id: @client_id, @@ -72,7 +70,10 @@ defmodule LineBot.TokenServerTest do expect(MockAPIClient, :post!, fn "https://api.line.me/v2/oauth/accessToken", {: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}'} 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 expect(MockAPIClient, :post!, fn "https://api.line.me/v2/oauth/revoke", {: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 end)