From 342e40214ada85bb15cacaf6014e69060d65fbe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Gagn=C3=A9?= Date: Wed, 27 Nov 2019 21:24:41 -0500 Subject: [PATCH] Add missing tests --- test/robots_SUITE.erl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/robots_SUITE.erl b/test/robots_SUITE.erl index 5cb69aa..8225a76 100644 --- a/test/robots_SUITE.erl +++ b/test/robots_SUITE.erl @@ -6,8 +6,16 @@ -compile(nowarn_export_all). -compile(export_all). +-define(UNSUPPORTED_CODE, 109). +-define(CODE_4XX, 418). +-define(CODE_5XX, 514). +-define(EMPTY_CONTENT, <<>>). + all() -> [ + return_error_on_unsupported_status_code, + allow_all_on_4xx_code, + disallow_all_on_5xx ]. init_per_testcase(_Name, Config) -> @@ -16,6 +24,20 @@ init_per_testcase(_Name, Config) -> end_per_testcase(_Name, Config) -> Config. +return_error_on_unsupported_status_code() -> + [{doc, "Given an unsupported status code, when parsing, then returns an error."}]. +return_error_on_unsupported_status_code(_Config) -> + ?assertMatch({error, _}, robots:parse(?EMPTY_CONTENT, ?UNSUPPORTED_CODE)). + +allow_all_on_4xx_code() -> + [{doc, "Given a 4XX status code, when parsing, then returns all allowed."}]. +allow_all_on_4xx_code(_Config) -> + ?assertMatch({ok, {allowed, all}}, robots:parse(?EMPTY_CONTENT, ?CODE_4XX)). + +disallow_all_on_5xx() -> + [{doc, "Given a 5XX status code, when parsing, then returns all disallowed."}]. +disallow_all_on_5xx(_Config) -> + ?assertMatch({ok, {disallowed, all}}, robots:parse(?EMPTY_CONTENT, ?CODE_5XX)). %%%=================================================================== %%% Internal functions