summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2015-09-05 16:02:34 +0100
committerdakkar <dakkar@thenautilus.net>2015-09-05 16:02:34 +0100
commitd2490ddef6e002dbc30ab5dcd14d751b64f82ad4 (patch)
tree553eba56dceca433e5fd69a06e4a983efd0f7821
parenttest passes (diff)
downloadWebCoso-p6-d2490ddef6e002dbc30ab5dcd14d751b64f82ad4.tar.gz
WebCoso-p6-d2490ddef6e002dbc30ab5dcd14d751b64f82ad4.tar.bz2
WebCoso-p6-d2490ddef6e002dbc30ab5dcd14d751b64f82ad4.zip
more tests
-rw-r--r--lib/WebCoso.pm4
-rw-r--r--t/tests/webcoso.t45
2 files changed, 38 insertions, 11 deletions
diff --git a/lib/WebCoso.pm b/lib/WebCoso.pm
index 46db3c0..5fe9a07 100644
--- a/lib/WebCoso.pm
+++ b/lib/WebCoso.pm
@@ -30,7 +30,9 @@ class WebCoso {
}
method put-file($dir,$basename,$lang,$ext,$contents) {
- $!tmpdir.child($dir).child("{$basename}.{$lang}.{$ext}").spurt($contents);
+ my $t = $!tmpdir.child($dir);
+ $t.mkdir;
+ $t.child("{$basename}.{$lang}.{$ext}").spurt($contents);
return;
}
diff --git a/t/tests/webcoso.t b/t/tests/webcoso.t
index a68d6d2..6712eff 100644
--- a/t/tests/webcoso.t
+++ b/t/tests/webcoso.t
@@ -6,7 +6,15 @@ use WebCoso;
sub cmp-files($a,$b,$msg) {
ok(
($a.defined and $b.defined and $a.keys eqv $b.keys and
- [and] map { $a{$_}.abspath eq $b{$_}.abspath }, $a.keys),
+ [and] map {
+ my $cmp = $b{$_};
+ if $cmp ~~ Callable {
+ $cmp.($a{$_})
+ }
+ else {
+ $a{$_}.abspath eq $cmp.abspath
+ }
+ }, $a.keys),
$msg,
);
}
@@ -25,15 +33,32 @@ $one.child('document.en.txt').spurt('foo');
my $wc = WebCoso.new(:$srcdir,:$destdir);
-my %one = $wc.get-files('one','document','txt');
+subtest {
+ my %one = $wc.get-files('one','document','txt');
-cmp-files(
- %one,
- {
- it => $one.child('document.it.txt'),
- en => $one.child('document.en.txt'),
- },
- 'get-files works',
-);
+ cmp-files(
+ %one,
+ {
+ it => $one.child('document.it.txt'),
+ en => $one.child('document.en.txt'),
+ },
+ 'get-files works',
+ );
+}, 'getting files';
+
+subtest {
+ $wc.put-file('two','document','en','txt',
+ 'something');
+ my %two = $wc.get-files('two','document','txt');
+
+ cmp-files(
+ %two,
+ {
+ en => { $^f.abspath ~~ /two\/document\.en\.txt$/ },
+ },
+ 'put-file works',
+ );
+
+}, 'putting files';
done-testing;