Permalink
Browse files

Add get_shortcode unit test.

  • Loading branch information...
1 parent 51c1dd1 commit 79ec70fc741022cc46dba98aca19b085ef495f8d @gavincarr committed Jul 24, 2012
Showing with 37 additions and 0 deletions.
  1. +31 −0 t/01_get_shortcode.t
  2. +6 −0 t/t01/db.yml
View
@@ -0,0 +1,31 @@
+# Test Shrtn::Utils::get_shortcode
+
+use Test::More 0.88;
+use YAML qw(LoadFile Dump);
+
+use FindBin qw($Bin);
+use lib "$Bin/../lib";
+use Shrtn::Utils qw(get_shortcode);
+
+my @urls = (
+ # Test new
+ [ 'http://www.identi.ca/' => '1cf' ],
+ [ 'http://www.twitter.com/' => '3Ou' ],
+ [ 'http://www.google.com/' => '5CC' ],
+ # Test existing
+ [ 'http://www.mysociety.org/2012/07/18/governments-dont-have-websites-governments-are-websites/' => 'PVp' ],
+ # Test existing custom
+ [ 'http://www.openfusion.net/' => 'ofn' ],
+);
+
+my $db = LoadFile "$Bin/t01/db.yml";
+ok($db && ref $db eq 'HASH', 'db loaded ok');
+
+for my $rec (@urls) {
+ my ($url, $expected_code) = @$rec;
+ my $code = get_shortcode($db, $url);
+ is($code, $expected_code, "get_shortcode for $url ok");
+}
+
+done_testing;
+
View
@@ -0,0 +1,6 @@
+---
+PVp: http://www.mysociety.org/2012/07/18/governments-dont-have-websites-governments-are-websites/
+busy: http://opinionator.blogs.nytimes.com/2012/06/30/the-busy-trap/
+gh: https://github.com/gavincarr/
+ofc: http://www.openfusion.com.au/
+ofn: http://www.openfusion.net/

0 comments on commit 79ec70f

Please sign in to comment.