Skip to content

Commit 6196dc9

Browse files
committed
Fix reduced test coverage
1 parent 8a56a35 commit 6196dc9

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

test/cadet/public/updater_test.exs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,19 @@ defmodule Cadet.Public.UpdaterTest do
5252
end
5353
end
5454

55-
test "Get announcements" do
56-
use_cassette "updater/get_announcements#1", custom: true do
57-
%{token: token, course_id: course_id} = Updater.get_api_params()
58-
assert {:ok, announcements} = Updater.get_announcements(token, course_id)
59-
assert is_list(announcements)
55+
describe "Get announcements" do
56+
test "Valid token" do
57+
use_cassette "updater/get_announcements#1", custom: true do
58+
%{token: token, course_id: course_id} = Updater.get_api_params()
59+
assert {:ok, announcements} = Updater.get_announcements(token, course_id)
60+
assert is_list(announcements)
61+
end
62+
end
63+
64+
test "Invalid token" do
65+
use_cassette "updater/get_announcements#2" do
66+
assert {:error, :bad_request} = Updater.get_announcements("t0k3n", "")
67+
end
6068
end
6169
end
6270

@@ -98,7 +106,7 @@ defmodule Cadet.Public.UpdaterTest do
98106

99107
test "Invalid token" do
100108
use_cassette "updater/handle_info#2", custom: true do
101-
api_params = Updater.get_api_params()
109+
api_params = %{Updater.get_api_params() | token: "bad_token"}
102110
assert {:noreply, new_api_params} = Updater.handle_info(:work, api_params)
103111
assert api_params.course_id == new_api_params.course_id
104112
assert String.length(new_api_params.token) == 480
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[
2+
{
3+
"request": {
4+
"body": "",
5+
"headers": [],
6+
"method": "get",
7+
"options": [],
8+
"request_body": "",
9+
"url": "https://ivle.nus.edu.sg/api/Lapi.svc/Announcements"
10+
},
11+
"response": {
12+
"binary": false,
13+
"body": "{\"Results\":[],\"Comments\":\"Invalid login!\",\"LastUpdate\":\"\\/Date(1530503822337+0800)\\/\",\"LastUpdate_js\":\"2018-07-02T11:57:02.3375561+08:00\"}",
14+
"headers": {
15+
"Cache-Control": "private",
16+
"Content-Type": "application/json",
17+
"Server": "Microsoft-IIS/8.5",
18+
"Request-Context": "appId=cid-v1:9bebd252-0be2-48b7-a1db-8e2b70524944",
19+
"Set-Cookie": "ASP.NET_SessionId=hxgayx5s3gmikr4kagjsqt0g; path=/; HttpOnly",
20+
"X-AspNet-Version": "4.0.30319",
21+
"X-Powered-By": "ASP.NET",
22+
"Date": "Mon, 02 Jul 2018 03:57:01 GMT",
23+
"Content-Length": "138"
24+
},
25+
"status_code": 200,
26+
"type": "ok"
27+
}
28+
}
29+
]

0 commit comments

Comments
 (0)