-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for useragent_string() and useragent_timeout()
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use warnings; | ||
use strict; | ||
use feature 'say'; | ||
|
||
use Tesla::API; | ||
use Test::More; | ||
|
||
my $constant_ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:98.0) Gecko/20100101 Firefox/98.0'; | ||
|
||
my $t = Tesla::API->new(unauthenticated => 1); | ||
|
||
is | ||
$t->useragent_string, | ||
$constant_ua_string, | ||
"useragent_string() returns proper default ok"; | ||
|
||
is | ||
$t->useragent_string('Test Browser'), | ||
'Test Browser', | ||
"Setting user agent works ok"; | ||
|
||
done_testing(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use warnings; | ||
use strict; | ||
use feature 'say'; | ||
|
||
use Tesla::API; | ||
use Test::More; | ||
|
||
my $constant_ua_timeout = 180; | ||
|
||
my $t = Tesla::API->new(unauthenticated => 1); | ||
|
||
is | ||
$t->useragent_timeout, | ||
$constant_ua_timeout, | ||
"useragent_timeout() returns proper default ok"; | ||
|
||
for ('*', '?', 'aa', '99a', 'aa9', '0.a', '-1', '-1.0', '1.') { | ||
my $ok = eval { $t->useragent_timeout($_); 1; }; | ||
is $ok, undef, "useragent_timeout() with '$_' param croaks ok"; | ||
} | ||
|
||
for (999, .2, 2.2, 10.10, 0.1) { | ||
is | ||
$t->useragent_timeout($_), | ||
$_, | ||
"Setting user agent to '$_' works ok"; | ||
} | ||
|
||
done_testing(); |