-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated tests to skip. updated docs to show our lack of confidence in…
… the service
- Loading branch information
Showing
9 changed files
with
171 additions
and
49 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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,23 +1,54 @@ | ||
use Test::More tests => 7; | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use Try::Tiny qw(try catch); | ||
|
||
BEGIN { use_ok WWW::Shorten::SnipURL }; | ||
BEGIN { use_ok('WWW::Shorten::SnipURL') or BAIL_OUT("Can't use!") }; | ||
can_ok('WWW::Shorten::SnipURL', qw(makealongerlink makeashorterlink)); | ||
can_ok('main', qw(makealongerlink makeashorterlink)); | ||
|
||
my $url = 'http://code.mag-sol.com/WWW-Shorten/WWW-Shorten.1.95.tar.gz'; | ||
my $code; | ||
my $prefix_RE = qr{http://sn(?:ip)?url\.com/}; | ||
my $prefix = 'http://snipurl.com/'; | ||
my $shortened = makeashorterlink($url); | ||
|
||
if ($shortened =~ m|\Q$prefix\E(\w+)|) { | ||
$code = $1; | ||
{ # blank call errors | ||
my $err = try { makeashorterlink() } catch { "no dice: $_" }; | ||
like($err, qr/^no dice/, 'makeashorterlink: error on empty call'); | ||
$err = undef; | ||
|
||
$err = try { makeashorterlink() } catch { "no dice: $_" }; | ||
like($err, qr/^no dice/, 'makealongerlink: error on empty call'); | ||
} | ||
|
||
like ( $shortened, qr/$prefix_RE$code/, 'make it shorter'); | ||
is ( makealongerlink($prefix.$code), $url, 'make it longer'); | ||
is ( makealongerlink($code), $url, 'make it longer by Id',); | ||
is ( makealongerlink($shortened), $url, 'make it long with what we were given'); | ||
SKIP: { | ||
skip "Can't run live tests", 10; | ||
my $err; | ||
my $shortened = try { makeashorterlink($url) } catch { $err=$_; undef }; | ||
is($err,undef, "makeashorterlink: no errors"); | ||
skip "Got an error trying to shorten", 9 if $err; | ||
ok($shortened, "makeashorterlink: got a response"); | ||
skip "Got no shortened response", 8 unless $shortened; | ||
like($shortened, qr{^http://sn(?:ip)?url\.com/\w+$}, 'makeashorterlink: good url'); | ||
|
||
my $code; | ||
if ($shortened =~ m{^http://sn(?:ip)?url\.com/(\w+)$}) { | ||
$code = $1; | ||
} | ||
ok($code, "makeashorterlink: got a short code"); | ||
|
||
$err = undef; | ||
my $longer = try { makealongerlink($prefix.$code) } catch { $err=$_; undef }; | ||
is($err, undef, "makealongerlink: whole - no errors"); | ||
is($longer,$url, "makealongerlink: whole - got back the URL"); | ||
|
||
$err = undef; $longer = undef; | ||
$longer = try { makealongerlink($code) } catch { $err=$_; undef }; | ||
is($err, undef, "makealongerlink: code - no errors"); | ||
is($longer,$url, "makealongerlink: code - got back the URL"); | ||
|
||
$err = undef; $longer = undef; | ||
$longer = try { makealongerlink($shortened) } catch { $err=$_; undef }; | ||
is($err, undef, "makealongerlink: shortened - no errors"); | ||
is($longer,$url, "makealongerlink: shortened - got back the URL"); | ||
} | ||
|
||
eval { &makeashorterlink() }; | ||
ok($@); | ||
eval { &makealongerlink() }; | ||
ok($@); | ||
done_testing(); |