summaryrefslogtreecommitdiff
path: root/t/tests/fileset.t
diff options
context:
space:
mode:
Diffstat (limited to 't/tests/fileset.t')
-rw-r--r--t/tests/fileset.t99
1 files changed, 99 insertions, 0 deletions
diff --git a/t/tests/fileset.t b/t/tests/fileset.t
new file mode 100644
index 0000000..7723dc2
--- /dev/null
+++ b/t/tests/fileset.t
@@ -0,0 +1,99 @@
+# -*- mode: perl6 -*-
+use Test;
+use lib 't/lib';
+use Test::WebCoso;
+use File::Temp;
+use WebCoso::FileSet;
+
+my $testdir = tempdir.IO;
+
+$testdir.child('document.it.tt').spurt('it');
+$testdir.child('document.en.rest.txt').spurt('en');
+$testdir.child('du2xhtml.xsl').spurt('<>');
+
+subtest {
+ my $fs1 = WebCoso::FileSet.new(
+ basename=>'document',
+ ext=>'tt',
+ path=>$testdir,
+ );
+ cmp-files(
+ $fs1,
+ { it => { $^x.contents eq 'it' } },
+ 'simple ext works',
+ );
+
+ my $fs2 = WebCoso::FileSet.new(
+ basename=>'document',
+ ext=>'rest.txt',
+ path=>$testdir,
+ );
+ cmp-files(
+ $fs2,
+ { en => { $^x.contents eq 'en' } },
+ 'harder ext works',
+ );
+
+ my $fs3 = WebCoso::FileSet.new(
+ files => [$testdir.child('du2xhtml.xsl')],
+ );
+ cmp-files(
+ $fs3,
+ { '' => { $^x.contents eq '<>' } },
+ 'direct files works',
+ );
+
+ my $fs4 = WebCoso::FileSet.new(
+ files-hash => {
+ xml => $testdir.child('du2xhtml.xsl'),
+ it => $testdir.child('document.it.tt'),
+ }
+ );
+ cmp-files(
+ $fs4,
+ {
+ xml => { $^x.contents eq '<>' },
+ it => { $^x.contents eq 'it' },
+ },
+ 'files hash works',
+ );
+},'construction';
+
+subtest {
+ my $fs-merged = WebCoso::FileSet.new(
+ basename=>'document',
+ ext=>'tt',
+ path=>$testdir,
+ ).merged-with(WebCoso::FileSet.new(
+ basename=>'document',
+ ext=>'rest.txt',
+ path=>$testdir,
+ ));
+ cmp-files(
+ $fs-merged,
+ {
+ it => { $^x.contents eq 'it' },
+ en => { $^x.contents eq 'en' },
+ },
+ 'merging works',
+ );
+},'merging';
+
+subtest {
+ my $fs1 = WebCoso::FileSet.new(
+ basename=>'document',
+ ext=>'tt',
+ path=>$testdir,
+ );
+ $fs1.set-for-lang('en',$testdir.child('document.en.rest.txt'));
+ cmp-files(
+ $fs1,
+ {
+ it => { $^x.contents eq 'it' },
+ en => { $^x.contents eq 'en' },
+ },
+ 'set-for-lang works',
+ );
+},'set-for-lang';
+
+done-testing;