aboutsummaryrefslogtreecommitdiff
path: root/pastebin/website-pastebin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2019-05-21 07:58:12 -0300
committerEuAndreh <eu@euandre.org>2019-05-21 08:09:47 -0300
commitcc224b7da6db158a72c3479e131a6ad999797313 (patch)
tree1b70559a58fe442df932bd136071681528f67f06 /pastebin/website-pastebin
parentAdd Hakyll _cache/ folder to .gitignore (diff)
downloadeuandre.org-cc224b7da6db158a72c3479e131a6ad999797313.tar.gz
euandre.org-cc224b7da6db158a72c3479e131a6ad999797313.tar.xz
Add actual tests to website CLI
Diffstat (limited to '')
-rwxr-xr-xpastebin/website-pastebin17
1 files changed, 15 insertions, 2 deletions
diff --git a/pastebin/website-pastebin b/pastebin/website-pastebin
index 6061c74..1171dcf 100755
--- a/pastebin/website-pastebin
+++ b/pastebin/website-pastebin
@@ -42,9 +42,11 @@ use Term::ANSIColor;
my $help = 0;
my $title = '';
+my $test = 0;
GetOptions(
'help|h|?' => \$help,
- 'title|t=s' => \$title
+ 'title|t=s' => \$title,
+ 'test|?' => \$test
) or pod2usage(-verbose => 1, -exitval => 2);
pod2usage(
-verbose => 2,
@@ -54,7 +56,7 @@ pod2usage(
-verbose => 1,
-exitval => 2,
-message => colored("Missing required --title argument.", "red")
-) if !$title;
+) if !$title && !$test;
# Taken from:
# https://stackoverflow.com/a/4009519
@@ -69,6 +71,17 @@ sub slugify {
return $input;
}
+if ($test) {
+ eval "use Test::More tests => 4"; die $@ if $@;
+ is(slugify("My Custom Title String"), "my-custom-title-string");
+ is(slugify("String with áccents and sym?bol-s."), "string-with-accents-and-symbol-s");
+ is(slugify("unicode-↓æđ-chars"), "unicode-aaa-chars");
+ is(slugify(" spaces and line
+break"), "spaces-and-line-break");
+ done_testing();
+ exit;
+}
+
our $dirname = dirname(__FILE__);
our $in = "$dirname/skeleton.org";
our $out;